{"id":24344,"library":"pykka","title":"Pykka","description":"Pykka is a Python implementation of the actor model, providing concurrency primitives for building distributed and concurrent systems. Version 4.4.2 runs on Python >=3.10. New releases are sporadic.","status":"active","version":"4.4.2","language":"python","source_language":"en","source_url":"https://github.com/jodal/pykka","tags":["actor-model","concurrency","distributed"],"install":[{"cmd":"pip install pykka","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Standard import","symbol":"Actor","correct":"from pykka import Actor"},{"note":"Preferred for I/O-bound tasks","symbol":"ThreadingActor","correct":"from pykka import ThreadingActor"},{"note":"Reference to an actor instance","symbol":"ActorRef","correct":"from pykka import ActorRef"},{"note":"Global registry of actors","symbol":"ActorRegistry","correct":"from pykka import ActorRegistry"},{"note":"getattr moved to top-level since v3","wrong":"from pykka.actor import getattr","symbol":"getattr","correct":"from pykka import getattr"}],"quickstart":{"code":"import pykka\n\nclass Greeter(pykka.ThreadingActor):\n    def __init__(self, greeting='Hi'):\n        super().__init__()\n        self.greeting = greeting\n\n    def on_receive(self, message):\n        return f'{self.greeting}, {message}'\n\nactor = Greeter.start(greeting='Hello').proxy()\nprint(actor.on_receive('World').get())  # Hello, World\nactor.stop()","lang":"python","description":"Define an actor class, start it, send a message, and stop."},"warnings":[{"fix":"Design actors as isolated units communicating via messages (dicts or immutable objects).","message":"Actors are not threadsafe; avoid sharing mutable state between actors. Use message passing only.","severity":"gotcha","affected_versions":"all"},{"fix":"Call actor.stop() or use a context manager: with Greeter.start() as actor: ...","message":"Unlike the standard library, Pykka actors must be stopped explicitly to release resources. ActorRegistry will not clean them up automatically.","severity":"gotcha","affected_versions":">=3.0"},{"fix":"Ensure on_receive always returns a value (or call actor.stop() explicitly without a return).","message":"In Pykka 4.x, on_receive must return a value or raise an exception; previously None was allowed and would cause hangs.","severity":"breaking","affected_versions":"4.0 - 4.4"},{"fix":"Use future.get() only outside actors, or use call() with a callback instead.","message":"Proxy() and get() are blocking. Using them inside an actor's on_receive can cause deadlocks.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install with 'pip install pykka' and verify Python version >=3.10.","cause":"Pykka not installed or wrong Python environment.","error":"ModuleNotFoundError: No module named 'pykka'"},{"fix":"Use MyActor.start() (class method) not my_actor.start().","cause":"Attempting to call start() on an instance instead of the class.","error":"AttributeError: 'MyActor' object has no attribute 'start'"},{"fix":"Ensure every on_receive returns a result. If no result, call actor.stop() and return a default.","cause":"Actor's on_receive never returned a value (or deadlocked).","error":"TimeoutError: Actor call timed out after ... seconds"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}