Coder Social home page Coder Social logo

mitmdump's People

Contributors

mocobk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mitmdump's Issues

threading异步执行报错

我想通过多线程的方式执行以下代码
因为m.run()会导致代码阻塞
`# sample1.py
import threading

from mitmdump import DumpMaster, Options
from mitmproxy.http import HTTPFlow

class AddHeader:
def init(self):
self.num = 0

def response(self, flow: HTTPFlow):
    self.num = self.num + 1
    flow.response.headers["count"] = str(self.num)

addons = [
AddHeader()
]

def run():
opts = Options(listen_host='0.0.0.0', listen_port=8888, scripts=file, keepserving=True)
m = DumpMaster(opts)
m.run()

if name == 'main':
t = threading.Thread(target=run)
t.start()`

但是会报以下的错误
Exception in thread Thread-1: Traceback (most recent call last): File "C:\Python37\lib\threading.py", line 917, in _bootstrap_inner self.run() File "C:\Python37\lib\threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "D:/2-Git/pyproject/PythonFile/1.我的项目/第三方包/pkg_mitmproxy/多线程版.py", line 24, in run m = DumpMaster(opts) File "C:\Python37\lib\site-packages\mitmdump\mitmdump.py", line 126, in __init__ super().__init__(options, with_termlog, with_dumper) File "C:\Python37\lib\site-packages\mitmproxy\tools\dump.py", line 24, in __init__ super().__init__(options) File "C:\Python37\lib\site-packages\mitmproxy\master.py", line 48, in __init__ asyncio.get_event_loop(), File "C:\Python37\lib\asyncio\events.py", line 644, in get_event_loop % threading.current_thread().name) RuntimeError: There is no current event loop in thread 'Thread-1'.
请问一下这个该怎么解决

或者有什么方法可以在执行
m.run()
后, 不阻塞代码
应为我想结合selenium在pyqt5中实现爬虫功能
谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.