Skip to content

Commit 94db0b8

Browse files
committed
Cleanup PR #85, restoring argument to run() for compat with existing programs that use pytak.
1 parent 6f92586 commit 94db0b8

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pytak/classes.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import ipaddress
2323
import logging
2424
import multiprocessing as mp
25-
import queue as _queue
2625
import random
2726

2827
import xml.etree.ElementTree as ET
@@ -108,12 +107,12 @@ async def run_once(self) -> None:
108107
await self.handle_data(data)
109108
await self.fts_compat()
110109

111-
async def run(self) -> None:
110+
async def run(self, _=-1) -> None:
112111
"""Run this Thread - calls run_once() in a loop."""
113-
self._logger.info("Run: %s", self.__class__.__name__)
112+
self._logger.info("Running: %s", self.__class__.__name__)
114113
while True:
115114
await self.run_once()
116-
await asyncio.sleep(0) # make sure other tasks have a chance to run
115+
await asyncio.sleep(0) # make sure other tasks have a chance to run
117116

118117

119118
class TXWorker(Worker):
@@ -204,6 +203,7 @@ async def handle_data(self, data: bytes) -> None:
204203

205204
async def readcot(self):
206205
"""Read CoT from the wire until we hit an event boundary."""
206+
cot = None
207207
try:
208208
if hasattr(self.reader, "readuntil"):
209209
cot = await self.reader.readuntil("</event>".encode("UTF-8"))
@@ -223,16 +223,17 @@ async def run_once(self) -> None:
223223
if self.reader:
224224
data: bytes = await self.readcot()
225225
if data:
226-
self._logger.debug("RX: %s", data)
226+
self._logger.debug("RX data: %s", data)
227227
self.queue.put_nowait(data)
228228

229-
async def run(self) -> None:
229+
async def run(self, _=-1) -> None:
230230
"""Run this worker."""
231-
self._logger.info("Run: %s", self.__class__.__name__)
231+
self._logger.info("Running: %s", self.__class__.__name__)
232232
while True:
233233
await self.run_once()
234234
await asyncio.sleep(0) # make sure other tasks have a chance to run
235235

236+
236237
class QueueWorker(Worker):
237238
"""Read non-CoT Messages from an async network client.
238239

0 commit comments

Comments
 (0)