We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `libqtile/core/session_manager.py`
Content:
```
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 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/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)

{"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"}], "after_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        asyncio.set_event_loop(eventloop)\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"}]}