{"id":16942441,"url":"https://github.com/defnull/pycopine","last_synced_at":"2025-06-10T22:02:45.182Z","repository":{"id":8376730,"uuid":"9947541","full_name":"defnull/pycopine","owner":"defnull","description":"Latency and fault tolerance library inspired by Hystrix.","archived":false,"fork":false,"pushed_at":"2013-09-10T23:19:24.000Z","size":248,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T19:53:09.965Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pycopine.readthedocs.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/defnull.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-08T22:43:12.000Z","updated_at":"2024-08-04T13:19:29.000Z","dependencies_parsed_at":"2022-09-14T07:12:01.095Z","dependency_job_id":null,"html_url":"https://github.com/defnull/pycopine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defnull%2Fpycopine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defnull%2Fpycopine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defnull%2Fpycopine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defnull%2Fpycopine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defnull","download_url":"https://codeload.github.com/defnull/pycopine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defnull%2Fpycopine/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259159609,"owners_count":22814489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T21:11:56.465Z","updated_at":"2025-06-10T22:02:44.828Z","avatar_url":"https://github.com/defnull.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Pycopine - Handle with Care\n===========================\n\nPycopine is a latency and fault tolerance library designed to isolate points of\naccess to remote systems, services and 3rd party libraries, stop cascading\nfailure and enable resilience in complex distributed systems where failure\nis inevitable.\n\nAs this copy-pasted text suggests, pycopine is heavily inspired by\n`Hystrix \u003chttps://github.com/Netflix/Hystrix\u003e`_. \n\nPrerequisites\n-------------\n\nPycopine requires Python 3.2+, but may be backportet to 2.7 in the future.\n\n(Planned) Features\n------------------\n\n* Detect and report failing services.\n* Short-circuit services that fail on high load to help them recover.\n* Monitor failure rates and performance metrics to detect bottlenecks.\n* Manage thread pool and queue sizes on demand, at runtime, from everywhere.\n* ... (more to come)\n\nExample\n-------\n\nLets say we want to speak to a remote service that is slow, unreliable or both:\n\n.. code-block:: python\n\n    import time\n    import random\n    \n    def crappy_service(value):\n        ''' The most useless piece of code ever.'''\n        time.sleep(5)\n        if 'OK' != random.choice(['OK', 'OK', 'SERVER ON FIRE']):\n            raise RuntimeError('We broke something :(')\n        return value\n\nYou could throw lots of threads and try/except clauses at the problem and hope\nto not break the internet. Or you could use pycopine:\n\n.. code-block:: python\n\n    from pycopine import Command\n    \n    class MyCommand(Command):\n        ''' Does nothing with the input, but with style. '''\n    \n        def run(self, value):\n            return crappy_service(value)\n\n        def fallback(self, value):\n            return 'some fallback value'\n\n    # Run and wait for the result\n    result = MyCommand('input').result()\n\n    # Give up after 2 seconds\n    result = MyCommand('input').result(timeout=2)\n\n    # Fire and forget\n    MyCommand('input').submit()\n\n    # Do stuff in parallel\n    foo = MyCommand('input').submit()\n    bar = MyCommand('input').submit()\n    results = [foo.result(), bar.result()]\n\n    # Change your mind midway through\n    foobar = MyCommand('input').submit()\n    if foobar.wait(timeout=2):\n        result = foobar.result()\n    else:\n        foobar.cancel(RuntimeError('We have no time for this!'))\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefnull%2Fpycopine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefnull%2Fpycopine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefnull%2Fpycopine/lists"}