{ "info": { "author": "okay", "author_email": "okay.zed+pltpy@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "## plaitpy-ipc\n\nThis module is an external module for plait.py that provides an ecosystem to\nrun multiple plaitpy processes in, as well as inter-markov process\ncommunication features like locks, queues and shared variables.\n\n### what can be simulated\n\n* simple [M/M/c queues](https://en.wikipedia.org/wiki/M/M/c_queue), like bank teller queues\n* kitchen and bathroom usage in a house\n* desk usage in a workspace\n* multiple agents browsing multiple websites\n* etc\n\n### self contained example\n\nThe follow is an ecosystem with a single lock. It starts with a parent process\nthat spawns children every now and then. The children can spawn more children\nand so on. The limitation is that only one child can be spawned per tick because of\nthe \"spawner\" lock.\n\n\n setup: |\n import plaitpy_ipc\n import json\n\n if not GLOBALS.ecosystem:\n GLOBALS.ecosystem = plaitpy_ipc.Ecosystem()\n GLOBALS.ECO = ecosystem.shared()\n\n ecosystem.add_lock(\"spawner\", capacity=1)\n\n\n fields:\n tick:\n lambda: ecosystem.get_tick()\n\n make_child:\n onlyif: random.random() > 0.9 and ECO.spawner.grab()\n lambda: ecosystem.spawn(\"spawner.yaml\")\n\n age:\n initial:\n lambda: 0\n lambda: prev.age + 1\n\n expired:\n onlyif: random.random() > 0.9 and this.age > 0\n lambda: ecosystem.expire()\n\n id:\n lambda: ecosystem.get_pid()\n\n\n print: |\n for r, p in ecosystem.gen_records():\n print(json.dumps(r))\n\n\nBecause this is a single yaml template for demonstration purposes, the parent\nprocess and children process are sharing the same file. A consequence of this\nis that the outermost parent process can not expire because it is not running\ninside the ecosystem. Also notice that the parent process is not included in\ngen_records.\n\n## ecosystem usage\n\nTo create an ecosystem, a parent template must exist that will run the\necosystem. In the parent template's print method, they will call\n`gen_records()`, causing all the processes in the ecosystem to tick forward.\n\nTo create a process, `spawn(template_name)` is used. To expire the current\nprocess, `expire()` is called from the process that should expire.\n\nThe parent template's fields will *not* be printed when using this pattern, so\nthey can be used to keep track of state information.\n\n## structures\n\nall resources should be declared ahead of time, using `add_queue`, `add_lock` and\n`add_quantity`. Once a resource is declared, it is available through the ecosystem's\nshared() variable.\n\n### locks\n\nTo synchronize usage of a resource, we use named Locks. The lock can be grabbed\nwith `grab()` by any process. There is no release function, though - as long as\na process keeps calling `grab()`, they will hold the lock. It takes one tick to\nrelease the lock by inactivity.\n\nAny processes that didn't grab the lock will receive False, while the process\nthat did grab the lock will receive True.\n\nLocks can have a capacity, which specifies how many individual processes can\nhold that lock at once.\n\n### queues\n\nQueues are similar to locks, except the order of which process tried to grab\nthe lock is retained in a FIFO manner. Similar to a lock, the queue unlocks\nimplicitly and takes one tick of inactivity to be released.\n\n## visualization\n\nA simple table visualizer exists to watch processes as long as they have an\n*id* and *tick* field in them. See the makefile's *bank* and *ecosystem* rules\nfor how to generate a `viz/output.js` file, then load `viz/viz.html` in a browser.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/plaitpy/plaitpy-ipc", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "plaitpy-ipc", "package_url": "https://pypi.org/project/plaitpy-ipc/", "platform": "", "project_url": "https://pypi.org/project/plaitpy-ipc/", "project_urls": { "Homepage": "http://github.com/plaitpy/plaitpy-ipc" }, "release_url": "https://pypi.org/project/plaitpy-ipc/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "a fake data inter markov process communication system", "version": "0.0.1" }, "last_serial": 3525973, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "cb7ad2b2f05558f0631bd5bd02f6631f", "sha256": "c70096536693c2a822ed196a8f3a7847a058fc5876130817469d7f0c3618fb95" }, "downloads": -1, "filename": "plaitpy_ipc-0.0.1.tar.gz", "has_sig": false, "md5_digest": "cb7ad2b2f05558f0631bd5bd02f6631f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5927, "upload_time": "2018-01-27T03:42:04", "url": "https://files.pythonhosted.org/packages/7f/d1/7d269abce904b8f549371af34a03c6738e5f14c050814f9fb65e3640e997/plaitpy_ipc-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cb7ad2b2f05558f0631bd5bd02f6631f", "sha256": "c70096536693c2a822ed196a8f3a7847a058fc5876130817469d7f0c3618fb95" }, "downloads": -1, "filename": "plaitpy_ipc-0.0.1.tar.gz", "has_sig": false, "md5_digest": "cb7ad2b2f05558f0631bd5bd02f6631f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5927, "upload_time": "2018-01-27T03:42:04", "url": "https://files.pythonhosted.org/packages/7f/d1/7d269abce904b8f549371af34a03c6738e5f14c050814f9fb65e3640e997/plaitpy_ipc-0.0.1.tar.gz" } ] }