mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 14:04:51 +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,6 +78,7 @@ class TCP:
|
|||
self.socket.close()
|
||||
|
||||
async def send(self, data: bytes):
|
||||
with await self.lock:
|
||||
self.writer.write(data)
|
||||
await self.writer.drain()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue