Skip to content

Commit 77a4ce1

Browse files
authored
Merge pull request #247 from jodal/thread-names
fix: Simplify the actor thread's name
2 parents d9c4a3c + 9dd731e commit 77a4ce1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/pykka/_threading.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55
import threading
66
import time
7+
from itertools import count
78
from typing import TYPE_CHECKING, Any, ClassVar, NamedTuple, TypeVar
89

910
from pykka import Actor, Future, Timeout
@@ -115,6 +116,9 @@ def set_get_hook(
115116
self._condition.notify_all()
116117

117118

119+
_actor_thread_counter = count(0)
120+
121+
118122
class ThreadingActor(Actor):
119123
"""Implementation of [`Actor`][pykka.Actor] using regular Python threads."""
120124

@@ -144,7 +148,9 @@ def _create_future() -> Future[Any]:
144148
return ThreadingFuture()
145149

146150
def _start_actor_loop(self) -> None:
147-
thread = threading.Thread(target=self._actor_loop)
148-
thread.name = thread.name.replace("Thread", self.__class__.__name__)
151+
thread = threading.Thread(
152+
target=self._actor_loop,
153+
name=f"{self.__class__.__name__}-{next(_actor_thread_counter)}",
154+
)
149155
thread.daemon = self.use_daemon_thread
150156
thread.start()

0 commit comments

Comments
 (0)