Skip to main content

Pykka/Injector integration module

Project description

Build status

pykka-injector is a module uniting Injector and Pykka. It’s only purpose is to allow you to inject dependencies into Pykka Actors.

Works with:

  • CPython 2.x >= 2.6, 3.x >= 3.2

  • PyPy >= 1.9

Platform independent.

Usage example

from injector import inject, Injector, InstanceProvider, Key, singleton
from pykka import ThreadingActor
from pykka_injector import ActorStarter

Config = Key('Config')

class MyActor(ThreadingActor):
    @inject(config=Config)
    def __init__(self, config, user):
        self.config = config
        self.user = user

def configure(binder):
    binder.bind(
        Config,
        to=InstanceProvider(dict(environment='dev')),
        scope=singleton,
    )

if __name__ == '__main__':
    injector = Injector(configure)
    starter = injector.get(ActorStarter)
    actor_ref = starter.start(MyActor, kwargs=dict(user='root'))

    actor_proxy = actor_ref.proxy()
    print(actor_proxy.config.get(), actor_proxy.user.get())

    actor_ref.stop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykka-injector-0.1.0.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file pykka-injector-0.1.0.tar.gz.

File metadata

File hashes

Hashes for pykka-injector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fd47684138cd116ea95e86c89f0b6ca70d8a59ed27a37496edf7d2fcfae8ce86
MD5 bc432ce0895bde03c7736c290c3818a4
BLAKE2b-256 0a0206c1c6e9b0babdb11f92047f16f5de22109917902cda0a41851ee824bb25

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page