Skip to content

Commit

Permalink
Replaced deprecated use of setName on thread objects
Browse files Browse the repository at this point in the history
  • Loading branch information
comrumino committed Nov 26, 2022
1 parent 6284667 commit 6a4638c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion rpyc/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from rpyc.lib.compat import maxint # noqa: F401


SPAWN_THREAD_PREFIX = 'RpycSpawnThread'


class MissingModule(object):
__slots__ = ["__name"]

Expand Down Expand Up @@ -85,7 +88,8 @@ def hasattr_static(obj, attr):
def spawn(*args, **kwargs):
"""Start and return daemon thread. ``spawn(func, *args, **kwargs)``."""
func, args = args[0], args[1:]
thread = threading.Thread(target=func, args=args, kwargs=kwargs)
str_id_pack = '-'.join([f'{i}' for i in get_id_pack(func)])
thread = threading.Thread(name=f'{SPAWN_THREAD_PREFIX}-{str_id_pack}', target=func, args=args, kwargs=kwargs)
thread.daemon = True
thread.start()
return thread
Expand Down
2 changes: 1 addition & 1 deletion rpyc/utils/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _listen(self):
self.workers = []
for i in range(self.nbthreads):
t = spawn(self._serve_clients)
t.setName(f"Worker{i}")
t.name = f"Worker{i}"
self.workers.append(t)
# setup a thread for polling inactive connections
self.polling_thread = spawn(self._poll_inactive_clients)
Expand Down

0 comments on commit 6a4638c

Please sign in to comment.