Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions localite/coil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from localite.flow.mrk import Receiver
from typing import Tuple, Dict, Any, Union
import json
from time import sleep
import time

def pythonize_values(v: str) -> Union[bool, None, str]:
"pythonize a dictionaries values"
Expand Down Expand Up @@ -48,13 +48,16 @@ class Coil:

"""

def __init__(self, coil: int = 0, address: Tuple[str, int] = ("127.0.0.1", 6667)):
def __init__(self, coil: int = 0, address: Tuple[str, int] = ("127.0.0.1", 6667), timeout=10):
host, port = address
self._push_mrk = partial(push, fmt="mrk", host=host, port=port)
self._push_loc = partial(push, fmt="loc", host=host, port=port)
self.receiver = Receiver(name="localite_marker")
self.receiver.start()
start_receiver_time = time.time()
while not self.receiver.is_running.is_set():
if time.time() > start_receiver_time + timeout:
raise ConnectionError("Could not connect to localite flow")
pass
self.id = coil

Expand Down