summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/third_party/websockets/example/deployment/nginx/app.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /testing/web-platform/tests/tools/third_party/websockets/example/deployment/nginx/app.py
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/tools/third_party/websockets/example/deployment/nginx/app.py')
-rw-r--r--testing/web-platform/tests/tools/third_party/websockets/example/deployment/nginx/app.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/third_party/websockets/example/deployment/nginx/app.py b/testing/web-platform/tests/tools/third_party/websockets/example/deployment/nginx/app.py
new file mode 100644
index 0000000000..24e6089756
--- /dev/null
+++ b/testing/web-platform/tests/tools/third_party/websockets/example/deployment/nginx/app.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import asyncio
+import os
+import signal
+
+import websockets
+
+
+async def echo(websocket):
+ async for message in websocket:
+ await websocket.send(message)
+
+
+async def main():
+ # Set the stop condition when receiving SIGTERM.
+ loop = asyncio.get_running_loop()
+ stop = loop.create_future()
+ loop.add_signal_handler(signal.SIGTERM, stop.set_result, None)
+
+ async with websockets.unix_serve(
+ echo,
+ path=f"{os.environ['SUPERVISOR_PROCESS_NAME']}.sock",
+ ):
+ await stop
+
+
+if __name__ == "__main__":
+ asyncio.run(main())