Skip to content

Commit

Permalink
attempt to use uvloop
Browse files Browse the repository at this point in the history
  • Loading branch information
spookybear0 committed Aug 9, 2024
1 parent 0774be7 commit f66d6f8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion web.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,20 @@ async def main() -> None:
app.static("assets", "assets", name="assets")

if __name__ == "__main__":
loop = asyncio.new_event_loop()
if sys.platform == "win32":
loop = asyncio.new_event_loop()
else:
import uvloop
loop = uvloop.new_event_loop()

asyncio.set_event_loop(loop)

try:
loop.run_until_complete(main())
except KeyboardInterrupt:
print("Exiting...")
else:
if sys.platform == "win32":
app.config.USE_UVLOOP = False
else:
app.config.USE_UVLOOP = True

0 comments on commit f66d6f8

Please sign in to comment.