# Moving to mitmproxy 3 as a module

**URL:** https://discourse.mitmproxy.org/t/moving-to-mitmproxy-3-as-a-module/934
**Category:** help
**Created:** [March 22, 2018, 10:17pm UTC](https://discourse.mitmproxy.org/t/moving-to-mitmproxy-3-as-a-module/934 "2018-03-22T22:17:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kamepl](https://avatars.discourse-cdn.com/v4/letter/k/90db22/32.png) [@kamepl](https://discourse.mitmproxy.org/u/kamepl)
#### Post date: [March 22, 2018, 10:17pm UTC](https://discourse.mitmproxy.org/t/moving-to-mitmproxy-3-as-a-module/934/1 "2018-03-22T22:17:28Z")

</div>

Hi,

I’m using mitmporxy module in my project just like in flowbasic.py example from mitmproxy 2.x. So in short it was like this (in my case I start a thread and I communicate with another process and send some XML files that I need to check):

```
class MyMaster(master.Master):
    def run(self):
        try:
            master.Master.run(self)
        except KeyboardInterrupt:
            self.shutdown()
    [..]
    @controller.handler
    def response(self, f):
        DO_MY_STUFF(f)
    [..]

opts = options.Options(cadir="~/.mitmproxy/")
config = ProxyConfig(opts)
server = ProxyServer(config)
m = MyMaster(opts, server)
m.run()

```

For the version 3 there is no example flowbasic.py and reading the docs and checking the source won’t give me a clue how to put response function.

Do anyone have such flowbasic.py for v3 prepared or some ideas?

---

<div class="post-metadata">

### Author: ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)
#### Post date: [March 23, 2018, 1:56pm UTC](https://discourse.mitmproxy.org/t/moving-to-mitmproxy-3-as-a-module/934/2 "2018-03-23T13:56:49Z")

</div>

Hi,

subclassing master.Master is deprecated for quite a while now. 😉 You should be able to achieve your task by writing a mitmproxy addon, see here: [https://docs.mitmproxy.org/stable/addons-overview/](https://docs.mitmproxy.org/stable/addons-overview/)

---

<div class="post-metadata">

### Author: ![kamepl](https://avatars.discourse-cdn.com/v4/letter/k/90db22/32.png) [@kamepl](https://discourse.mitmproxy.org/u/kamepl)
#### Post date: [March 26, 2018, 7:03am UTC](https://discourse.mitmproxy.org/t/moving-to-mitmproxy-3-as-a-module/934/3 "2018-03-26T07:03:31Z")

</div>

ok… But I need to make it as a class in the same file (so I can provide parameters - multiprocess queue). I have tried but until now - without luck ☹

I’m getting only the running and done events to happen. How to make it properly to get the response event working ?
