Thread to send packets periodically Args: sock: socket where packet is sent periodically pkt: packet or list of packets to send interval: interval between two packets
(self, sock, pkt, interval=0.5, ignore_exceptions=True)
| 4033 | |
| 4034 | class PeriodicSenderThread(threading.Thread): |
| 4035 | def __init__(self, sock, pkt, interval=0.5, ignore_exceptions=True): |
| 4036 | # type: (Any, _PacketIterable, float, bool) -> None |
| 4037 | """ Thread to send packets periodically |
| 4038 | |
| 4039 | Args: |
| 4040 | sock: socket where packet is sent periodically |
| 4041 | pkt: packet or list of packets to send |
| 4042 | interval: interval between two packets |
| 4043 | """ |
| 4044 | if not isinstance(pkt, list): |
| 4045 | self._pkts = [cast("Packet", pkt)] # type: _PacketIterable |
| 4046 | else: |
| 4047 | self._pkts = pkt |
| 4048 | self._socket = sock |
| 4049 | self._stopped = threading.Event() |
| 4050 | self._enabled = threading.Event() |
| 4051 | self._enabled.set() |
| 4052 | self._interval = interval |
| 4053 | self._ignore_exceptions = ignore_exceptions |
| 4054 | threading.Thread.__init__(self) |
| 4055 | |
| 4056 | def enable(self): |
| 4057 | # type: () -> None |