Skip to content

Commit

Permalink
Merge pull request #643 from tirkarthi/fix-threading
Browse files Browse the repository at this point in the history
Fix threading module related DeprecationWarning.
  • Loading branch information
zsquareplusc committed Aug 17, 2023
2 parents c3ecedf + 3c88952 commit 52c73fc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/wxTerminal.py
Expand Up @@ -166,13 +166,13 @@ def __init__(self, *args, **kwds):
# end wxGlade
self.__attach_events() # register events
self.OnPortSettings(None) # call setup dialog on startup, opens port
if not self.alive.isSet():
if not self.alive.is_set():
self.Close()

def StartThread(self):
"""Start the receiver thread"""
self.thread = threading.Thread(target=self.ComPortThread)
self.thread.setDaemon(1)
self.thread.daemon = True
self.alive.set()
self.thread.start()
self.serial.rts = True
Expand Down Expand Up @@ -332,7 +332,7 @@ def ComPortThread(self):
Thread that handles the incoming traffic. Does the basic input
transformation (newlines) and generates an SerialRxEvent
"""
while self.alive.isSet():
while self.alive.is_set():
b = self.serial.read(self.serial.in_waiting or 1)
if b:
# newline transformation
Expand Down
2 changes: 1 addition & 1 deletion serial/rfc2217.py
Expand Up @@ -462,7 +462,7 @@ def open(self):

self.is_open = True
self._thread = threading.Thread(target=self._telnet_read_loop)
self._thread.setDaemon(True)
self._thread.daemon = True
self._thread.setName('pySerial RFC 2217 reader thread for {}'.format(self._port))
self._thread.start()

Expand Down
2 changes: 1 addition & 1 deletion serial/urlhandler/protocol_cp2110.py
Expand Up @@ -99,7 +99,7 @@ def open(self):
else:
self.is_open = True
self._thread = threading.Thread(target=self._hid_read_loop)
self._thread.setDaemon(True)
self._thread.daemon = True
self._thread.setName('pySerial CP2110 reader thread for {}'.format(self._port))
self._thread.start()

Expand Down
8 changes: 4 additions & 4 deletions test/test.py
Expand Up @@ -106,8 +106,8 @@ def run(self):
self.serial.write(b"E")
self.serial.flush()

def isSet(self):
return self.x.isSet()
def is_set(self):
return self.x.is_set()

def stop(self):
self.stopped = 1
Expand All @@ -130,8 +130,8 @@ def test2_ReadEmpty(self):
"""no timeout: after port open, the input buffer must be empty (read).
a character is sent after some time to terminate the test (SendEvent)."""
c = self.s.read(1)
if not (self.event.isSet() and c == b'E'):
self.fail("expected marker (evt={!r}, c={!r})".format(self.event.isSet(), c))
if not (self.event.is_set() and c == b'E'):
self.fail("expected marker (evt={!r}, c={!r})".format(self.event.is_set(), c))


class Test2_Forever(unittest.TestCase):
Expand Down

0 comments on commit 52c73fc

Please sign in to comment.