mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-06 23: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):
|
def __init__(self, proxy: dict):
|
||||||
self.proxy = proxy
|
self.proxy = proxy
|
||||||
|
|
||||||
|
self.lock = asyncio.Lock()
|
||||||
|
|
||||||
self.socket = socks.socksocket()
|
self.socket = socks.socksocket()
|
||||||
self.reader = None # type: asyncio.StreamReader
|
self.reader = None # type: asyncio.StreamReader
|
||||||
self.writer = None # type: asyncio.StreamWriter
|
self.writer = None # type: asyncio.StreamWriter
|
||||||
|
|
@ -76,8 +78,9 @@ class TCP:
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
|
|
||||||
async def send(self, data: bytes):
|
async def send(self, data: bytes):
|
||||||
self.writer.write(data)
|
with await self.lock:
|
||||||
await self.writer.drain()
|
self.writer.write(data)
|
||||||
|
await self.writer.drain()
|
||||||
|
|
||||||
async def recv(self, length: int = 0):
|
async def recv(self, length: int = 0):
|
||||||
data = b""
|
data = b""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue