prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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
  
  </issue>
  <code>
  [start of mitmproxy/__init__.py]
  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 of mitmproxy/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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())
  
verification_info: {"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"}]}