prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Can't use asyncio event loop in widgets
  I am creating a widget that uses asyncio to run some external command (with `asyncio.create_subprocess_exec`). It doesn't work, and raises the `RuntimeError("Cannot add child handler, the child watcher does not have a loop attached")` exception instead.
  
  If my understanding of the code is correct, calling `set_event_loop` after `new_event_loop` should fix this issue, but I'm not sure whether it will cause other problems.
  
  </issue>
  <code>
  [start of libqtile/core/session_manager.py]
  1 import asyncio
  2 import os
  3 
  4 from libqtile import ipc
  5 from libqtile.backend import base
  6 from libqtile.core.manager import Qtile
  7 
  8 
  9 class SessionManager:
  10     def __init__(
  11         self, kore: base.Core, config, *, fname: str = None, no_spawn=False, state=None
  12     ) -> None:
  13         """Manages a qtile session
  14 
  15         :param kore:
  16             The core backend to use for the session.
  17         :param config:
  18             The configuration to use for the qtile instance.
  19         :param fname:
  20             The file name to use as the qtile socket file.
  21         :param no_spawn:
  22             If the instance has already been started, then don't re-run the
  23             startup once hook.
  24         :param state:
  25             The state to restart the qtile instance with.
  26         """
  27         eventloop = asyncio.new_event_loop()
  28 
  29         self.qtile = Qtile(kore, config, eventloop, no_spawn=no_spawn, state=state)
  30 
  31         if fname is None:
  32             # Dots might appear in the host part of the display name
  33             # during remote X sessions. Let's strip the host part first
  34             display_name = kore.display_name
  35             display_number = display_name.partition(":")[2]
  36             if "." not in display_number:
  37                 display_name += ".0"
  38             fname = ipc.find_sockfile(display_name)
  39 
  40         if os.path.exists(fname):
  41             os.unlink(fname)
  42         self.server = ipc.Server(fname, self.qtile.server.call, eventloop)
  43 
  44     def loop(self) -> None:
  45         """Run the event loop"""
  46         with self.server:
  47             self.qtile.loop()
  48
  [end of libqtile/core/session_manager.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/libqtile/core/session_manager.py b/libqtile/core/session_manager.py
  --- a/libqtile/core/session_manager.py
  +++ b/libqtile/core/session_manager.py
  @@ -25,6 +25,7 @@
               The state to restart the qtile instance with.
           """
           eventloop = asyncio.new_event_loop()
  +        asyncio.set_event_loop(eventloop)
   
           self.qtile = Qtile(kore, config, eventloop, no_spawn=no_spawn, state=state)
  
verification_info: {"golden_diff": "diff --git a/libqtile/core/session_manager.py b/libqtile/core/session_manager.py\n--- a/libqtile/core/session_manager.py\n+++ b/libqtile/core/session_manager.py\n@@ -25,6 +25,7 @@\n             The state to restart the qtile instance with.\n         \"\"\"\n         eventloop = asyncio.new_event_loop()\n+        asyncio.set_event_loop(eventloop)\n \n         self.qtile = Qtile(kore, config, eventloop, no_spawn=no_spawn, state=state)\n", "issue": "Can't use asyncio event loop in widgets\nI am creating a widget that uses asyncio to run some external command (with `asyncio.create_subprocess_exec`). It doesn't work, and raises the `RuntimeError(\"Cannot add child handler, the child watcher does not have a loop attached\")` exception instead.\r\n\r\nIf my understanding of the code is correct, calling `set_event_loop` after `new_event_loop` should fix this issue, but I'm not sure whether it will cause other problems.\n", "before_files": [{"content": "import asyncio\nimport os\n\nfrom libqtile import ipc\nfrom libqtile.backend import base\nfrom libqtile.core.manager import Qtile\n\n\nclass SessionManager:\n    def __init__(\n        self, kore: base.Core, config, *, fname: str = None, no_spawn=False, state=None\n    ) -> None:\n        \"\"\"Manages a qtile session\n\n        :param kore:\n            The core backend to use for the session.\n        :param config:\n            The configuration to use for the qtile instance.\n        :param fname:\n            The file name to use as the qtile socket file.\n        :param no_spawn:\n            If the instance has already been started, then don't re-run the\n            startup once hook.\n        :param state:\n            The state to restart the qtile instance with.\n        \"\"\"\n        eventloop = asyncio.new_event_loop()\n\n        self.qtile = Qtile(kore, config, eventloop, no_spawn=no_spawn, state=state)\n\n        if fname is None:\n            # Dots might appear in the host part of the display name\n            # during remote X sessions. Let's strip the host part first\n            display_name = kore.display_name\n            display_number = display_name.partition(\":\")[2]\n            if \".\" not in display_number:\n                display_name += \".0\"\n            fname = ipc.find_sockfile(display_name)\n\n        if os.path.exists(fname):\n            os.unlink(fname)\n        self.server = ipc.Server(fname, self.qtile.server.call, eventloop)\n\n    def loop(self) -> None:\n        \"\"\"Run the event loop\"\"\"\n        with self.server:\n            self.qtile.loop()\n", "path": "libqtile/core/session_manager.py"}]}