mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-18 06:11:49 -05:00
Lock around client reset
We now have multiple places where we call reset in case a network connection fails, so now there is a mutex lock around the reset method.
This commit is contained in:
parent
71d72adf06
commit
50e491bab4
@ -1,11 +1,13 @@
|
||||
import abc
|
||||
import datetime
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
|
||||
import aprslib
|
||||
from aprslib.exceptions import LoginError
|
||||
from oslo_config import cfg
|
||||
import wrapt
|
||||
|
||||
from aprsd import exception
|
||||
from aprsd.clients import aprsis, fake, kiss
|
||||
@ -28,6 +30,10 @@ factory = None
|
||||
|
||||
@singleton
|
||||
class APRSClientStats:
|
||||
|
||||
lock = threading.Lock()
|
||||
|
||||
@wrapt.synchronized(lock)
|
||||
def stats(self, serializable=False):
|
||||
client = factory.create()
|
||||
stats = {
|
||||
@ -58,6 +64,7 @@ class Client:
|
||||
|
||||
connected = False
|
||||
filter = None
|
||||
lock = threading.Lock()
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""This magic turns this into a singleton."""
|
||||
@ -97,6 +104,7 @@ class Client:
|
||||
packet_list.PacketList().tx(packet)
|
||||
self.client.send(packet)
|
||||
|
||||
@wrapt.synchronized(lock)
|
||||
def reset(self):
|
||||
"""Call this to force a rebuild/reconnect."""
|
||||
LOG.info("Resetting client connection.")
|
||||
|
Loading…
Reference in New Issue
Block a user