TelenkovDmitry 1 ヶ月 前
コミット
1d54c48ba5
2 ファイル変更23 行追加0 行削除
  1. 18 0
      python_net/asyncio/debug.py
  2. 5 0
      python_net/asyncio/first_app/server.py

+ 18 - 0
python_net/asyncio/debug.py

@@ -0,0 +1,18 @@
+import asyncio
+from util import async_timed
+
+
+@async_timed()
+async def cpu_bound_work() -> int:
+    counter = 0
+    for i in range(10000000):
+        counter += 1
+    return counter
+
+
+async def main() -> None:
+    task_one = asyncio.create_task(cpu_bound_work())
+    await task_one
+
+
+asyncio.run(main(), debug=True)

+ 5 - 0
python_net/asyncio/first_app/server.py

@@ -0,0 +1,5 @@
+import socket
+
+def foo():
+    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)