回答編集履歴
1
文法の修正
answer
CHANGED
@@ -12,12 +12,9 @@
|
|
12
12
|
import asyncio
|
13
13
|
|
14
14
|
class Hoge:
|
15
|
-
def
|
15
|
+
async def connect(self, uri):
|
16
|
-
self.
|
16
|
+
self.ws : websockets.WebSocketCommonProtocol = await websockets.connect(uri)
|
17
17
|
|
18
|
-
async def connect(self):
|
19
|
-
self.ws : websockets.WebSocketCommonProtocol = await websockets.connect(self.uri)
|
20
|
-
|
21
18
|
def __aiter__(self):
|
22
19
|
return self
|
23
20
|
|
@@ -27,7 +24,7 @@
|
|
27
24
|
|
28
25
|
async def main():
|
29
26
|
hoge = Hoge()
|
30
|
-
await hoge.connect()
|
27
|
+
await hoge.connect('ws://localhost:8000/')
|
31
28
|
async for msg in hoge:
|
32
29
|
print(msg)
|
33
30
|
|