MCPcopy
hub / github.com/mitmproxy/mitmproxy / SyncSignal

Function SyncSignal

mitmproxy/utils/signals.py:99–121  ·  view source on GitHub ↗

Create a synchronous signal with the given function signature for receivers. Example: s = SyncSignal(lambda event: None) # all receivers must accept a single "event" argument. def receiver(event): print(event) s.connect(receiver) s.send("foo")

(receiver_spec: Callable[P, None])

Source from the content-addressed store, hash-verified

97
98# noinspection PyPep8Naming
99def SyncSignal(receiver_spec: Callable[P, None]) -> _SyncSignal[P]:
100 """
101 Create a synchronous signal with the given function signature for receivers.
102
103 Example:
104
105 s = SyncSignal(lambda event: None) # all receivers must accept a single "event" argument.
106 def receiver(event):
107 print(event)
108
109 s.connect(receiver)
110 s.send("foo") # prints foo
111 s.send(event="bar") # prints bar
112
113 def receiver2():
114 ...
115
116 s.connect(receiver2) # mypy complains about receiver2 not having the right signature
117
118 s2 = SyncSignal(lambda: None) # this signal has no arguments
119 s2.send()
120 """
121 return cast(_SyncSignal[P], _SyncSignal())
122
123
124# noinspection PyPep8Naming

Callers 3

test_sync_signalFunction · 0.90
test_signal_weakrefFunction · 0.90

Calls 1

_SyncSignalClass · 0.85

Tested by 3

test_sync_signalFunction · 0.72
test_signal_weakrefFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…