mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-30 04:24:50 +00:00
Lock TCP send()
This commit is contained in:
parent
335a2e06c8
commit
984e989a4b
1 changed files with 5 additions and 2 deletions
|
|
@ -39,6 +39,8 @@ class TCP:
|
|||
def __init__(self, proxy: dict):
|
||||
self.proxy = proxy
|
||||
|
||||
self.lock = asyncio.Lock()
|
||||
|
||||
self.socket = socks.socksocket()
|
||||
self.reader = None # type: asyncio.StreamReader
|
||||
self.writer = None # type: asyncio.StreamWriter
|
||||
|
|
@ -76,8 +78,9 @@ class TCP:
|
|||
self.socket.close()
|
||||
|
||||
async def send(self, data: bytes):
|
||||
self.writer.write(data)
|
||||
await self.writer.drain()
|
||||
with await self.lock:
|
||||
self.writer.write(data)
|
||||
await self.writer.drain()
|
||||
|
||||
async def recv(self, length: int = 0):
|
||||
data = b""
|
||||
|
|
|
|||
Loading…
Reference in a new issue