We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
When too many requests come simultaneously, mitmdump called an error and quited [ValueError: too many file descriptors in select()]
#### Problem Description
A clear and concise description of what the bug is.
When too many requests come simultaneously, mitmdump called an error and quited.
Traceback (most recent call last):
  File "mitmdump", line 3, in <module>
  File "mitmproxy\tools\main.py", line 147, in mitmdump
  File "mitmproxy\tools\main.py", line 114, in run
  File "mitmproxy\master.py", line 76, in run
  File "mitmproxy\master.py", line 59, in run_loop
  File "mitmproxy\master.py", line 95, in shutdown
  File "asyncio\base_events.py", line 629, in run_until_complete
  File "asyncio\base_events.py", line 596, in run_forever
  File "asyncio\base_events.py", line 1854, in _run_once
  File "selectors.py", line 324, in select
  File "selectors.py", line 315, in _select
ValueError: too many file descriptors in select()
[77436] Failed to execute script 'mitmdump' due to unhandled exception!

I googled the error message, and found the following answer. Don't know if it's related.
https://stackoverflow.com/questions/57182009/why-am-i-getting-an-valueerror-too-many-file-descriptors-in-select

#### Steps to reproduce the behavior:
1. I use the following command
`mitmdump.exe -p 8080 --anticomp -q -s "d:\redirect-router.py"`
In the script, I re-write the host for a specific URL
2. 
3. 

#### System Information
Paste the output of "mitmproxy --version" here.
mitmproxy --version
Mitmproxy: 7.0.2 binary
Python:    3.9.6
OpenSSL:   OpenSSL 1.1.1k  25 Mar 2021
Platform:  Windows-10-10.0.18363-SP0

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mitmproxy/__init__.py`
Content:
```
1 import asyncio
2 import sys
3 
4 if sys.platform == 'win32':
5     # workaround for
6     # https://github.com/tornadoweb/tornado/issues/2751
7     # https://www.tornadoweb.org/en/stable/index.html#installation
8     # (copied multiple times in the codebase, please remove all occurrences)
9     asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
10
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mitmproxy/__init__.py b/mitmproxy/__init__.py
--- a/mitmproxy/__init__.py
+++ b/mitmproxy/__init__.py
@@ -1,9 +0,0 @@
-import asyncio
-import sys
-
-if sys.platform == 'win32':
-    # workaround for
-    # https://github.com/tornadoweb/tornado/issues/2751
-    # https://www.tornadoweb.org/en/stable/index.html#installation
-    # (copied multiple times in the codebase, please remove all occurrences)
-    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

{"golden_diff": "diff --git a/mitmproxy/__init__.py b/mitmproxy/__init__.py\n--- a/mitmproxy/__init__.py\n+++ b/mitmproxy/__init__.py\n@@ -1,9 +0,0 @@\n-import asyncio\n-import sys\n-\n-if sys.platform == 'win32':\n-    # workaround for\n-    # https://github.com/tornadoweb/tornado/issues/2751\n-    # https://www.tornadoweb.org/en/stable/index.html#installation\n-    # (copied multiple times in the codebase, please remove all occurrences)\n-    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\n", "issue": "When too many requests come simultaneously, mitmdump called an error and quited [ValueError: too many file descriptors in select()]\n#### Problem Description\r\nA clear and concise description of what the bug is.\r\nWhen too many requests come simultaneously, mitmdump called an error and quited.\r\nTraceback (most recent call last):\r\n  File \"mitmdump\", line 3, in <module>\r\n  File \"mitmproxy\\tools\\main.py\", line 147, in mitmdump\r\n  File \"mitmproxy\\tools\\main.py\", line 114, in run\r\n  File \"mitmproxy\\master.py\", line 76, in run\r\n  File \"mitmproxy\\master.py\", line 59, in run_loop\r\n  File \"mitmproxy\\master.py\", line 95, in shutdown\r\n  File \"asyncio\\base_events.py\", line 629, in run_until_complete\r\n  File \"asyncio\\base_events.py\", line 596, in run_forever\r\n  File \"asyncio\\base_events.py\", line 1854, in _run_once\r\n  File \"selectors.py\", line 324, in select\r\n  File \"selectors.py\", line 315, in _select\r\nValueError: too many file descriptors in select()\r\n[77436] Failed to execute script 'mitmdump' due to unhandled exception!\r\n\r\nI googled the error message, and found the following answer. Don't know if it's related.\r\nhttps://stackoverflow.com/questions/57182009/why-am-i-getting-an-valueerror-too-many-file-descriptors-in-select\r\n\r\n#### Steps to reproduce the behavior:\r\n1. I use the following command\r\n`mitmdump.exe -p 8080 --anticomp -q -s \"d:\\redirect-router.py\"`\r\nIn the script, I re-write the host for a specific URL\r\n2. \r\n3. \r\n\r\n#### System Information\r\nPaste the output of \"mitmproxy --version\" here.\r\nmitmproxy --version\r\nMitmproxy: 7.0.2 binary\r\nPython:    3.9.6\r\nOpenSSL:   OpenSSL 1.1.1k  25 Mar 2021\r\nPlatform:  Windows-10-10.0.18363-SP0\n", "before_files": [{"content": "import asyncio\nimport sys\n\nif sys.platform == 'win32':\n    # workaround for\n    # https://github.com/tornadoweb/tornado/issues/2751\n    # https://www.tornadoweb.org/en/stable/index.html#installation\n    # (copied multiple times in the codebase, please remove all occurrences)\n    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\n", "path": "mitmproxy/__init__.py"}], "after_files": [{"content": "", "path": "mitmproxy/__init__.py"}]}