We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Unable to start server -- Running run_async.py failed
**Describe the bug**
[2019-04-14 19:22:02 +0800] [21512] [INFO] Goin' Fast @ http://0.0.0.0:8000
[2019-04-14 19:22:02 +0800] [21512] [ERROR] Unable to start server
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\venom\lib\site-packages\sanic\server.py", line 745, in serve
    http_server = loop.run_until_complete(server_coroutine)
  File "C:\ProgramData\Anaconda3\envs\venom\lib\asyncio\base_events.py", line 571, in run_until_complete
    self.run_forever()
  File "C:\ProgramData\Anaconda3\envs\venom\lib\asyncio\base_events.py", line 529, in run_forever
    'Cannot run the event loop while another loop is running')
RuntimeError: Cannot run the event loop while another loop is running

**Code snippet**
Relevant source code, make sure to remove what is not necessary.

https://github.com/huge-success/sanic/blob/master/examples/run_async.py

**Expected behavior**
A clear and concise description of what you expected to happen.


**Environment (please complete the following information):**
 - OS: [e.g. iOS]
 - Version [e.g. 0.8.3]
Window and Linux, Python 3.6 or 3.7 don't work

**Additional context**
Add any other context about the problem here.


Is this example still work ?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/log_request_id.py`
Content:
```
1 '''
2 Based on example from https://github.com/Skyscanner/aiotask-context
3 and `examples/{override_logging,run_async}.py`.
4 
5 Needs https://github.com/Skyscanner/aiotask-context/tree/52efbc21e2e1def2d52abb9a8e951f3ce5e6f690 or newer
6 
7 $ pip install git+https://github.com/Skyscanner/aiotask-context.git
8 '''
9 
10 import asyncio
11 import uuid
12 import logging
13 from signal import signal, SIGINT
14 
15 from sanic import Sanic
16 from sanic import response
17 
18 import uvloop
19 import aiotask_context as context
20 
21 log = logging.getLogger(__name__)
22 
23 
24 class RequestIdFilter(logging.Filter):
25     def filter(self, record):
26         record.request_id = context.get('X-Request-ID')
27         return True
28 
29 
30 LOG_SETTINGS = {
31     'version': 1,
32     'disable_existing_loggers': False,
33     'handlers': {
34         'console': {
35             'class': 'logging.StreamHandler',
36             'level': 'DEBUG',
37             'formatter': 'default',
38             'filters': ['requestid'],
39         },
40     },
41     'filters': {
42         'requestid': {
43             '()': RequestIdFilter,
44         },
45     },
46     'formatters': {
47         'default': {
48             'format': '%(asctime)s %(levelname)s %(name)s:%(lineno)d %(request_id)s | %(message)s',
49         },
50     },
51     'loggers': {
52         '': {
53             'level': 'DEBUG',
54             'handlers': ['console'],
55             'propagate': True
56         },
57     }
58 }
59 
60 
61 app = Sanic(__name__, log_config=LOG_SETTINGS)
62 
63 
64 @app.middleware('request')
65 async def set_request_id(request):
66     request_id = request.headers.get('X-Request-ID') or str(uuid.uuid4())
67     context.set("X-Request-ID", request_id)
68 
69 
70 @app.route("/")
71 async def test(request):
72     log.debug('X-Request-ID: %s', context.get('X-Request-ID'))
73     log.info('Hello from test!')
74     return response.json({"test": True})
75 
76 
77 if __name__ == '__main__':
78     asyncio.set_event_loop(uvloop.new_event_loop())
79     server = app.create_server(host="0.0.0.0", port=8000)
80     loop = asyncio.get_event_loop()
81     loop.set_task_factory(context.task_factory)
82     task = asyncio.ensure_future(server)
83     try:
84         loop.run_forever()
85     except:
86         loop.stop()
87
```

Path: `examples/run_async.py`
Content:
```
1 from sanic import Sanic
2 from sanic import response
3 from signal import signal, SIGINT
4 import asyncio
5 import uvloop
6 
7 app = Sanic(__name__)
8 
9 
10 @app.route("/")
11 async def test(request):
12     return response.json({"answer": "42"})
13 
14 asyncio.set_event_loop(uvloop.new_event_loop())
15 server = app.create_server(host="0.0.0.0", port=8000)
16 loop = asyncio.get_event_loop()
17 task = asyncio.ensure_future(server)
18 signal(SIGINT, lambda s, f: loop.stop())
19 try:
20     loop.run_forever()
21 except:
22     loop.stop()
23
```
--- 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/examples/log_request_id.py b/examples/log_request_id.py
--- a/examples/log_request_id.py
+++ b/examples/log_request_id.py
@@ -76,7 +76,7 @@
 
 if __name__ == '__main__':
     asyncio.set_event_loop(uvloop.new_event_loop())
-    server = app.create_server(host="0.0.0.0", port=8000)
+    server = app.create_server(host="0.0.0.0", port=8000, return_asyncio_server=True)
     loop = asyncio.get_event_loop()
     loop.set_task_factory(context.task_factory)
     task = asyncio.ensure_future(server)
diff --git a/examples/run_async.py b/examples/run_async.py
--- a/examples/run_async.py
+++ b/examples/run_async.py
@@ -12,7 +12,7 @@
     return response.json({"answer": "42"})
 
 asyncio.set_event_loop(uvloop.new_event_loop())
-server = app.create_server(host="0.0.0.0", port=8000)
+server = app.create_server(host="0.0.0.0", port=8000, return_asyncio_server=True)
 loop = asyncio.get_event_loop()
 task = asyncio.ensure_future(server)
 signal(SIGINT, lambda s, f: loop.stop())

{"golden_diff": "diff --git a/examples/log_request_id.py b/examples/log_request_id.py\n--- a/examples/log_request_id.py\n+++ b/examples/log_request_id.py\n@@ -76,7 +76,7 @@\n \n if __name__ == '__main__':\n     asyncio.set_event_loop(uvloop.new_event_loop())\n-    server = app.create_server(host=\"0.0.0.0\", port=8000)\n+    server = app.create_server(host=\"0.0.0.0\", port=8000, return_asyncio_server=True)\n     loop = asyncio.get_event_loop()\n     loop.set_task_factory(context.task_factory)\n     task = asyncio.ensure_future(server)\ndiff --git a/examples/run_async.py b/examples/run_async.py\n--- a/examples/run_async.py\n+++ b/examples/run_async.py\n@@ -12,7 +12,7 @@\n     return response.json({\"answer\": \"42\"})\n \n asyncio.set_event_loop(uvloop.new_event_loop())\n-server = app.create_server(host=\"0.0.0.0\", port=8000)\n+server = app.create_server(host=\"0.0.0.0\", port=8000, return_asyncio_server=True)\n loop = asyncio.get_event_loop()\n task = asyncio.ensure_future(server)\n signal(SIGINT, lambda s, f: loop.stop())\n", "issue": "Unable to start server -- Running run_async.py failed\n**Describe the bug**\r\n[2019-04-14 19:22:02 +0800] [21512] [INFO] Goin' Fast @ http://0.0.0.0:8000\r\n[2019-04-14 19:22:02 +0800] [21512] [ERROR] Unable to start server\r\nTraceback (most recent call last):\r\n  File \"C:\\ProgramData\\Anaconda3\\envs\\venom\\lib\\site-packages\\sanic\\server.py\", line 745, in serve\r\n    http_server = loop.run_until_complete(server_coroutine)\r\n  File \"C:\\ProgramData\\Anaconda3\\envs\\venom\\lib\\asyncio\\base_events.py\", line 571, in run_until_complete\r\n    self.run_forever()\r\n  File \"C:\\ProgramData\\Anaconda3\\envs\\venom\\lib\\asyncio\\base_events.py\", line 529, in run_forever\r\n    'Cannot run the event loop while another loop is running')\r\nRuntimeError: Cannot run the event loop while another loop is running\r\n\r\n**Code snippet**\r\nRelevant source code, make sure to remove what is not necessary.\r\n\r\nhttps://github.com/huge-success/sanic/blob/master/examples/run_async.py\r\n\r\n**Expected behavior**\r\nA clear and concise description of what you expected to happen.\r\n\r\n\r\n**Environment (please complete the following information):**\r\n - OS: [e.g. iOS]\r\n - Version [e.g. 0.8.3]\r\nWindow and Linux, Python 3.6 or 3.7 don't work\r\n\r\n**Additional context**\r\nAdd any other context about the problem here.\r\n\r\n\r\nIs this example still work ?\n", "before_files": [{"content": "'''\nBased on example from https://github.com/Skyscanner/aiotask-context\nand `examples/{override_logging,run_async}.py`.\n\nNeeds https://github.com/Skyscanner/aiotask-context/tree/52efbc21e2e1def2d52abb9a8e951f3ce5e6f690 or newer\n\n$ pip install git+https://github.com/Skyscanner/aiotask-context.git\n'''\n\nimport asyncio\nimport uuid\nimport logging\nfrom signal import signal, SIGINT\n\nfrom sanic import Sanic\nfrom sanic import response\n\nimport uvloop\nimport aiotask_context as context\n\nlog = logging.getLogger(__name__)\n\n\nclass RequestIdFilter(logging.Filter):\n    def filter(self, record):\n        record.request_id = context.get('X-Request-ID')\n        return True\n\n\nLOG_SETTINGS = {\n    'version': 1,\n    'disable_existing_loggers': False,\n    'handlers': {\n        'console': {\n            'class': 'logging.StreamHandler',\n            'level': 'DEBUG',\n            'formatter': 'default',\n            'filters': ['requestid'],\n        },\n    },\n    'filters': {\n        'requestid': {\n            '()': RequestIdFilter,\n        },\n    },\n    'formatters': {\n        'default': {\n            'format': '%(asctime)s %(levelname)s %(name)s:%(lineno)d %(request_id)s | %(message)s',\n        },\n    },\n    'loggers': {\n        '': {\n            'level': 'DEBUG',\n            'handlers': ['console'],\n            'propagate': True\n        },\n    }\n}\n\n\napp = Sanic(__name__, log_config=LOG_SETTINGS)\n\n\n@app.middleware('request')\nasync def set_request_id(request):\n    request_id = request.headers.get('X-Request-ID') or str(uuid.uuid4())\n    context.set(\"X-Request-ID\", request_id)\n\n\n@app.route(\"/\")\nasync def test(request):\n    log.debug('X-Request-ID: %s', context.get('X-Request-ID'))\n    log.info('Hello from test!')\n    return response.json({\"test\": True})\n\n\nif __name__ == '__main__':\n    asyncio.set_event_loop(uvloop.new_event_loop())\n    server = app.create_server(host=\"0.0.0.0\", port=8000)\n    loop = asyncio.get_event_loop()\n    loop.set_task_factory(context.task_factory)\n    task = asyncio.ensure_future(server)\n    try:\n        loop.run_forever()\n    except:\n        loop.stop()\n", "path": "examples/log_request_id.py"}, {"content": "from sanic import Sanic\nfrom sanic import response\nfrom signal import signal, SIGINT\nimport asyncio\nimport uvloop\n\napp = Sanic(__name__)\n\n\n@app.route(\"/\")\nasync def test(request):\n    return response.json({\"answer\": \"42\"})\n\nasyncio.set_event_loop(uvloop.new_event_loop())\nserver = app.create_server(host=\"0.0.0.0\", port=8000)\nloop = asyncio.get_event_loop()\ntask = asyncio.ensure_future(server)\nsignal(SIGINT, lambda s, f: loop.stop())\ntry:\n    loop.run_forever()\nexcept:\n    loop.stop()\n", "path": "examples/run_async.py"}], "after_files": [{"content": "'''\nBased on example from https://github.com/Skyscanner/aiotask-context\nand `examples/{override_logging,run_async}.py`.\n\nNeeds https://github.com/Skyscanner/aiotask-context/tree/52efbc21e2e1def2d52abb9a8e951f3ce5e6f690 or newer\n\n$ pip install git+https://github.com/Skyscanner/aiotask-context.git\n'''\n\nimport asyncio\nimport uuid\nimport logging\nfrom signal import signal, SIGINT\n\nfrom sanic import Sanic\nfrom sanic import response\n\nimport uvloop\nimport aiotask_context as context\n\nlog = logging.getLogger(__name__)\n\n\nclass RequestIdFilter(logging.Filter):\n    def filter(self, record):\n        record.request_id = context.get('X-Request-ID')\n        return True\n\n\nLOG_SETTINGS = {\n    'version': 1,\n    'disable_existing_loggers': False,\n    'handlers': {\n        'console': {\n            'class': 'logging.StreamHandler',\n            'level': 'DEBUG',\n            'formatter': 'default',\n            'filters': ['requestid'],\n        },\n    },\n    'filters': {\n        'requestid': {\n            '()': RequestIdFilter,\n        },\n    },\n    'formatters': {\n        'default': {\n            'format': '%(asctime)s %(levelname)s %(name)s:%(lineno)d %(request_id)s | %(message)s',\n        },\n    },\n    'loggers': {\n        '': {\n            'level': 'DEBUG',\n            'handlers': ['console'],\n            'propagate': True\n        },\n    }\n}\n\n\napp = Sanic(__name__, log_config=LOG_SETTINGS)\n\n\n@app.middleware('request')\nasync def set_request_id(request):\n    request_id = request.headers.get('X-Request-ID') or str(uuid.uuid4())\n    context.set(\"X-Request-ID\", request_id)\n\n\n@app.route(\"/\")\nasync def test(request):\n    log.debug('X-Request-ID: %s', context.get('X-Request-ID'))\n    log.info('Hello from test!')\n    return response.json({\"test\": True})\n\n\nif __name__ == '__main__':\n    asyncio.set_event_loop(uvloop.new_event_loop())\n    server = app.create_server(host=\"0.0.0.0\", port=8000, return_asyncio_server=True)\n    loop = asyncio.get_event_loop()\n    loop.set_task_factory(context.task_factory)\n    task = asyncio.ensure_future(server)\n    try:\n        loop.run_forever()\n    except:\n        loop.stop()\n", "path": "examples/log_request_id.py"}, {"content": "from sanic import Sanic\nfrom sanic import response\nfrom signal import signal, SIGINT\nimport asyncio\nimport uvloop\n\napp = Sanic(__name__)\n\n\n@app.route(\"/\")\nasync def test(request):\n    return response.json({\"answer\": \"42\"})\n\nasyncio.set_event_loop(uvloop.new_event_loop())\nserver = app.create_server(host=\"0.0.0.0\", port=8000, return_asyncio_server=True)\nloop = asyncio.get_event_loop()\ntask = asyncio.ensure_future(server)\nsignal(SIGINT, lambda s, f: loop.stop())\ntry:\n    loop.run_forever()\nexcept:\n    loop.stop()\n", "path": "examples/run_async.py"}]}