mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-29 19:08:44 +00:00
08895e9ba6
- restructure examples (fix #4031) - remove example dependencies from setup.py, we do not need special dependencies for our supported addons. - unify how we generate docs from code - improve example docs
18 lines
663 B
Python
18 lines
663 B
Python
"""
|
|
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.
|
|
"""
|
|
import time
|
|
|
|
from mitmproxy.script import concurrent
|
|
|
|
|
|
@concurrent # Remove this and see what happens
|
|
def request(flow):
|
|
# 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))
|
|
time.sleep(5)
|
|
print("start request: %s%s" % (flow.request.host, flow.request.path))
|