Added a bit of sleeping every 100 attempts
This commit is contained in:
parent
b61dc0efa8
commit
897fbea54b
|
@ -108,13 +108,17 @@ class AsyncBotManager:
|
|||
async with AsyncSimpleClient(http_session=http) as sio:
|
||||
await sio.connect(f"{self.base}/socket.io")
|
||||
while not self._shutdown:
|
||||
index, expected = choice(list(self.difference.items()))
|
||||
diff = list(self.difference.items())
|
||||
for _ in range(100):
|
||||
index, expected = choice(diff)
|
||||
y, x = divmod(index, 1000)
|
||||
current = self.canvas.getpixel((x, y)) > 0 # type: ignore
|
||||
if current != expected:
|
||||
print(bot_index, "swap", x, y)
|
||||
print(f"[{bot_index:2d}] swap {x:3d} {y:3d}")
|
||||
await sio.emit("toggle_bit", {"index": index})
|
||||
await asyncio.sleep(0.25)
|
||||
break
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
async def __aenter__(self):
|
||||
self._listener_task = asyncio.create_task(self.listener())
|
||||
|
|
Loading…
Reference in New Issue