mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
fix compatibility with Python <3.10
This commit is contained in:
parent
1af095bcf8
commit
a7d473c1c1
3 changed files with 11 additions and 3 deletions
|
|
@ -16,7 +16,7 @@ unified_options = {}
|
|||
async def dump():
|
||||
for tool_name, master in masters.items():
|
||||
opts = options.Options()
|
||||
inst = master(opts)
|
||||
_ = master(opts)
|
||||
for key, option in optmanager.dump_dicts(opts).items():
|
||||
if key in unified_options:
|
||||
unified_options[key]['tools'].append(tool_name)
|
||||
|
|
|
|||
|
|
@ -20,13 +20,19 @@ class Master:
|
|||
event_loop: asyncio.AbstractEventLoop
|
||||
|
||||
def __init__(self, opts, event_loop: Optional[asyncio.AbstractEventLoop] = None):
|
||||
self.should_exit = asyncio.Event()
|
||||
self.options: options.Options = opts or options.Options()
|
||||
self.commands = command.CommandManager(self)
|
||||
self.addons = addonmanager.AddonManager(self)
|
||||
self.log = log.Log(self)
|
||||
self.event_loop = event_loop or asyncio.get_running_loop()
|
||||
|
||||
# We expect an active event loop here already because some addons
|
||||
# may want to spawn tasks during the initial configuration phase,
|
||||
# which happens before run().
|
||||
self.event_loop = event_loop or asyncio.get_running_loop()
|
||||
try:
|
||||
self.should_exit = asyncio.Event()
|
||||
except RuntimeError:
|
||||
self.should_exit = asyncio.Event(loop=self.event_loop)
|
||||
mitmproxy_ctx.master = self
|
||||
mitmproxy_ctx.log = self.log
|
||||
mitmproxy_ctx.options = self.options
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ async def test_simple():
|
|||
assert asyncio_utils.task_repr(task) == "127.0.0.1:42313: ttask (age: 0s)"
|
||||
await asyncio.sleep(0)
|
||||
assert "newname" in asyncio_utils.task_repr(task)
|
||||
delattr(task, "created")
|
||||
asyncio_utils.task_repr(task)
|
||||
asyncio_utils.cancel_task(task, "bye")
|
||||
await asyncio.sleep(0)
|
||||
assert task.cancelled()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue