{"id":13463852,"url":"https://github.com/muayyad-alsadi/python-PooledProcessMixIn","last_synced_at":"2025-03-25T09:31:11.309Z","repository":{"id":4159543,"uuid":"5274011","full_name":"muayyad-alsadi/python-PooledProcessMixIn","owner":"muayyad-alsadi","description":"Fast Concurrent Pool of preforked-processes and threads MixIn for python's socket server","archived":false,"fork":false,"pushed_at":"2012-08-10T20:40:16.000Z","size":443,"stargazers_count":31,"open_issues_count":5,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T16:21:47.930Z","etag":null,"topics":["pool","preforked-processes","python","python-socket-server","thread"],"latest_commit_sha":null,"homepage":null,"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/muayyad-alsadi.png","metadata":{"files":{"readme":"README.md","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":"2012-08-02T15:07:08.000Z","updated_at":"2023-01-10T09:27:22.000Z","dependencies_parsed_at":"2022-09-10T08:51:22.842Z","dependency_job_id":null,"html_url":"https://github.com/muayyad-alsadi/python-PooledProcessMixIn","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muayyad-alsadi%2Fpython-PooledProcessMixIn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muayyad-alsadi%2Fpython-PooledProcessMixIn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muayyad-alsadi%2Fpython-PooledProcessMixIn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muayyad-alsadi%2Fpython-PooledProcessMixIn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muayyad-alsadi","download_url":"https://codeload.github.com/muayyad-alsadi/python-PooledProcessMixIn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245435104,"owners_count":20614829,"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":["pool","preforked-processes","python","python-socket-server","thread"],"created_at":"2024-07-31T14:00:29.373Z","updated_at":"2025-03-25T09:31:08.894Z","avatar_url":"https://github.com/muayyad-alsadi.png","language":"Python","readme":"PooledProcessMixIn For Python\n=============================\n![Python Logo](http://www.python.org/images/python-logo.gif)\n\nFast Concurrent Pool of preforked-processes and threads Mix-in for python's socket server\nReplace the usual ThreadingMixIn and ForkingMixIn\n\nThis is a pure-python module that provides asynchronous mix-in\nsimilar to standard ThreadingMixIn and ForkingMixIn\nbut provides better performance by utilizing a pool\nof processes forked at initialization time\neach process allocate a pool of given number of threads\n\n\nInstallation and Dependencies\n-----------------------------\n\nThis module has no external dependencies other than the standard python library.\n\nTo get the latest development snapshot type the following command\n\ngit clone https://github.com/muayyad-alsadi/python-PooledProcessMixIn.git\n\nExample\n-------\n\n\n    from PooledProcessMixIn import PooledProcessMixIn\n    from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer\n    \n    # ... define MyTestHandler somewhere\n    \n    class MyHTTPTest (PooledProcessMixIn, HTTPServer):\n        def __init__(self):\n            self._process_n=7  # if not set will default to number of CPU cores\n            self._thread_n=64  # if not set will default to number of threads\n            HTTPServer.__init__(self, ('127.0.0.1',8888), MyTestHandler)\n            self._init_pool() # this is optional, will be called automatically\n            print \"listing on http://127.0.0.1:8888/\"\n\n\nDetails\n-------\n\nYou can set initial number of processes by setting `self._process_n` before calling `self._init_pool()`\n\nYou can set initial number of threads for each forked process by setting self._thread_n before calling `self._init_pool()`\n\nYou should call `self._init_pool()` AFTER super class `__init__` but\nif you did not call it, it will be called automatically when we get first request\n\nWhen Benchmarked against ThreadingMixIn and ForkingMixIn, it gives double performance (was able to handle about 1,500 request per second while other mix-ins reached 800 requests/second )\n\n    siege -b -c 100 -t10s localhost:8888/test\n          Date \u0026 Time,  Trans,  Elap Time,  Data Trans,  Resp Time,  Trans Rate,  Throughput,  Concurrent,    OKAY,   Failed\n    2012-08-02 12:51:47,  14663,       9.58,           0,       0.01,     1530.58,        0.00,       22.87,   14663,       0\n    2012-08-02 12:52:44,   7653,       9.58,           0,       0.04,      798.85,        0.00,       29.42,    7653,       5\n    2012-08-02 12:53:14,   7726,       9.47,           0,       0.05,      815.84,        0.00,       43.57,    7726,       0\n\n\nCan I use it to run my Django applications ?\n--------------------------------------------\n\nYes, Django provides WSGI application which can be used like the wsgi-demo included in this packages\n\n    import sys, os\n        \n    from PooledProcessMixIn import PooledProcessMixIn\n    from wsgiref.simple_server import make_server, WSGIServer\n    os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"mysite.settings\")\n        \n    d=os.path.dirname(__file__)\n    sys.path.insert(0, d)\n    sys.path.insert(0, os.path.join(d, \"..\"))\n        \n    from django import VERSION as DJ_VERSION\n    if DJ_VERSION\u003e=(1,4):\n        from django.core.wsgi import get_wsgi_application\n    else:\n        from django.core.handlers.wsgi import WSGIHandler as get_wsgi_application\n        \n    class WSGIServerPool(PooledProcessMixIn, WSGIServer):\n        pass\n        \n    application = get_wsgi_application()\n    make_server('127.0.0.1', 8080, application, server_class=WSGIServerPool).serve_forever()\n\n","funding_links":[],"categories":["Python"],"sub_categories":["Gists"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuayyad-alsadi%2Fpython-PooledProcessMixIn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuayyad-alsadi%2Fpython-PooledProcessMixIn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuayyad-alsadi%2Fpython-PooledProcessMixIn/lists"}