enforcing type better
This commit is contained in:
@@ -17,7 +17,7 @@ def threaded(fn):
|
||||
|
||||
class IPCServer:
|
||||
''' Create a listener so that other instances send requests back to existing instance. '''
|
||||
def __init__(self, conn_type="socket"):
|
||||
def __init__(self, conn_type: str = "socket"):
|
||||
self.is_ipc_alive = False
|
||||
self._conn_type = conn_type
|
||||
self.ipc_authkey = b'app-ipc'
|
||||
@@ -30,7 +30,7 @@ class IPCServer:
|
||||
self.ipc_port = 8888
|
||||
|
||||
@threaded
|
||||
def create_ipc_server(self):
|
||||
def create_ipc_server(self) -> None:
|
||||
if self._conn_type == "socket":
|
||||
if os.path.exists(self.ipc_address):
|
||||
return
|
||||
@@ -74,7 +74,7 @@ class IPCServer:
|
||||
listener.close()
|
||||
|
||||
|
||||
def send_ipc_message(self, message="Empty Data..."):
|
||||
def send_ipc_message(self, message: str = "Empty Data...") -> None:
|
||||
try:
|
||||
if self._conn_type == "socket":
|
||||
conn = Client(address=self.ipc_address, family="AF_UNIX", authkey=self.ipc_authkey)
|
||||
@@ -83,5 +83,6 @@ class IPCServer:
|
||||
|
||||
conn.send(message)
|
||||
conn.send('close connection')
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
print(repr(e))
|
||||
|
||||
Reference in New Issue
Block a user