This repository was archived by the owner on Jul 1, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
trinity/components/builtin/ethstats Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
import asyncio
2
2
import datetime
3
3
import json
4
- import typing
4
+
5
+ from typing import (
6
+ Any ,
7
+ Dict ,
8
+ NamedTuple ,
9
+ )
5
10
6
11
import websockets
7
12
@@ -19,10 +24,10 @@ def timestamp_ms() -> int:
19
24
return round (datetime .datetime .utcnow ().timestamp () * 1000 )
20
25
21
26
22
- EthstatsData = typing . Dict [str , typing . Any ]
27
+ EthstatsData = Dict [str , Any ]
23
28
24
29
25
- class EthstatsMessage (typing . NamedTuple ):
30
+ class EthstatsMessage (NamedTuple ):
26
31
command : str
27
32
data : EthstatsData
28
33
@@ -56,12 +61,12 @@ async def _run(self) -> None:
56
61
async def recv_handler (self ) -> None :
57
62
while self .is_operational :
58
63
try :
59
- json_string : str = await self .websocket .recv ()
64
+ json_string = await self .websocket .recv ()
60
65
except websockets .ConnectionClosed as e :
61
66
self .logger .debug2 ("Connection closed: %s" , e )
62
67
await self .cancel ()
63
68
try :
64
- message : EthstatsMessage = self .deserialize_message (json_string )
69
+ message : EthstatsMessage = self .deserialize_message (str ( json_string ) )
65
70
except EthstatsException as e :
66
71
self .logger .warning ('Cannot parse message from server: %s' % e )
67
72
return
You can’t perform that action at this time.
0 commit comments