MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / subscribe

Method subscribe

mitmproxy/optmanager.py:147–159  ·  view source on GitHub ↗

Subscribe a callable to the .changed signal, but only for a specified list of options. The callable should accept arguments (options, updated), and may raise an OptionsError. The event will automatically be unsubscribed if the callable goes out of scope.

(self, func, opts)

Source from the content-addressed store, hash-verified

145 raise e
146
147 def subscribe(self, func, opts):
148 """
149 Subscribe a callable to the .changed signal, but only for a
150 specified list of options. The callable should accept arguments
151 (options, updated), and may raise an OptionsError.
152
153 The event will automatically be unsubscribed if the callable goes out of scope.
154 """
155 for i in opts:
156 if i not in self._options:
157 raise exceptions.OptionsError("No such option: %s" % i)
158
159 self._subscriptions.append((signals.make_weak_ref(func), set(opts)))
160
161 def _notify_subscribers(self, updated) -> None:
162 cleanup = False

Callers 15

test_subscribeFunction · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
runningMethod · 0.80
__init__Method · 0.80
__init__Method · 0.80
IfFunction · 0.80
PfFunction · 0.80
constructorMethod · 0.80
oFunction · 0.80
gFunction · 0.80

Calls 2

setFunction · 0.85
appendMethod · 0.45

Tested by 2

test_subscribeFunction · 0.64
__init__Method · 0.64