Skip to content

Commit ae87451

Browse files
committed
Initial code dump
1 parent d1bee93 commit ae87451

File tree

2 files changed

+528
-0
lines changed

2 files changed

+528
-0
lines changed

signal_tester.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import state_signals
2+
import time
3+
from multiprocessing import Process
4+
5+
responder = state_signals.SignalResponder(responder_name="fakeresp", log_level="DEBUG")
6+
def _listener():
7+
for signal in responder.listen():
8+
print(signal)
9+
if "tag" in signal and signal["tag"] == "bad":
10+
ras = 0
11+
else:
12+
ras = 1
13+
responder.respond(signal["publisher_id"], signal["event"], ras)
14+
init = Process(target=_listener)
15+
init.start()
16+
17+
sig_ex = state_signals.SignalExporter("fakemark", log_level="DEBUG")
18+
print("\nBENCHMARK INIT TEST\n")
19+
sig_ex.initialize(legal_events=["benchmark-start", "benchmark-stop"])
20+
time.sleep(1)
21+
print("Proof of response (subs): " + str(sig_ex.subs))
22+
time.sleep(1)
23+
24+
print("\nBENCHMARK START TEST\n")
25+
result = sig_ex.publish_signal("benchmark-start", metadata={"something": "cool info"})
26+
time.sleep(1)
27+
print(f"SUBS CLEARED! Result code: {result}")
28+
time.sleep(1)
29+
30+
print("\nBENCHMARK STOP TEST\n")
31+
result = sig_ex.publish_signal("benchmark-stop", metadata={"tool": "give bad resp"}, tag="bad")
32+
time.sleep(1)
33+
print(f"SUBS CLEARED! Result code: {result}")
34+
time.sleep(1)
35+
36+
print("\nBENCHMARK SHUTDOWN TEST\n")
37+
print("Listening: " + str(sig_ex.init_listener.is_alive()))
38+
sig_ex.shutdown()
39+
time.sleep(1)
40+
print("Listening: " + str(sig_ex.init_listener.is_alive()))
41+
print("NO LONGER LISTENING, DONE")
42+
43+
init.terminate()
44+

0 commit comments

Comments
 (0)