mirror of
https://github.com/Dinnerbone/mcstatus.git
synced 2026-04-06 03:51:23 +08:00
timeout bedrock status comms
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import asyncio
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
from time import perf_counter
|
from time import perf_counter
|
||||||
@@ -56,10 +57,11 @@ class BedrockServerStatus:
|
|||||||
start = perf_counter()
|
start = perf_counter()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stream = await asyncio_dgram.connect((self.host, self.port))
|
conn = asyncio_dgram.connect((self.host, self.port))
|
||||||
|
stream = await asyncio.wait_for(conn, timeout=self.timeout)
|
||||||
|
|
||||||
await stream.send(self.request_status_data)
|
await asyncio.wait_for(stream.send(self.request_status_data), timeout=self.timeout)
|
||||||
data, _ = await stream.recv()
|
data, _ = await asyncio.wait_for(stream.recv(), timeout=self.timeout)
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
stream.close()
|
stream.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user