-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-server.py
More file actions
executable file
·39 lines (27 loc) · 879 Bytes
/
run-server.py
File metadata and controls
executable file
·39 lines (27 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding:utf-8 -*-
#!/usr/bin/env python
#import gevent
#from gevent import monkey; monkey.patch_all()
#gevent.config.loop = "libuv"
import asyncio
import uvicorn
from uvicorn.loops.uvloop import uvloop_setup
from braggy.backend import server
async def start_uvicorn():
app = server.init_server()
uvicorn.run(app, host='0.0.0.0', port=8000)
async def run_gevent():
gevent.get_hub().loop.run(nowait=True, once=True)
await asyncio.sleep(1)
async def main(loop):
ge_task = loop.create_task(run_gevent())
uv_task = loop.create_task(start_uvicorn())
await asyncio.wait([uv_task, ge_task])
# if __name__ == '__main__':
# uvloop_setup()
# loop = asyncio.get_event_loop()
# loop.run_until_complete(main(loop))
# loop.close()
if __name__ == '__main__':
app = server.init_server()
uvicorn.run(app, host='0.0.0.0', port=8080)