2020-06-22 23:53:39 +00:00
|
|
|
"""
|
|
|
|
Make events hooks non-blocking.
|
|
|
|
|
|
|
|
When event hooks are decorated with @concurrent, they will be run in their own thread, freeing the main event loop.
|
|
|
|
Please note that this generally opens the door to race conditions and decreases performance if not required.
|
|
|
|
"""
|
2013-12-15 01:43:16 +00:00
|
|
|
import time
|
2016-10-27 19:55:24 +00:00
|
|
|
|
2016-02-16 19:49:10 +00:00
|
|
|
from mitmproxy.script import concurrent
|
2013-12-15 01:43:16 +00:00
|
|
|
|
2014-09-05 13:16:20 +00:00
|
|
|
|
2014-09-08 14:02:31 +00:00
|
|
|
@concurrent # Remove this and see what happens
|
2016-07-08 01:37:33 +00:00
|
|
|
def request(flow):
|
2020-04-03 15:18:35 +00:00
|
|
|
# This is ugly in mitmproxy's UI, but you don't want to use mitmproxy.ctx.log from a different thread.
|
|
|
|
print("handle request: %s%s" % (flow.request.host, flow.request.path))
|
2013-12-15 01:43:16 +00:00
|
|
|
time.sleep(5)
|
2020-04-03 15:18:35 +00:00
|
|
|
print("start request: %s%s" % (flow.request.host, flow.request.path))
|