{ "info": { "author": "Ryan Bourgeois", "author_email": "bluedragonx@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7" ], "description": "Detach\n======\nFork and detach the current process.\n\n[![Build Status](https://travis-ci.org/BlueDragonX/detach.svg)](https://travis-ci.org/BlueDragonX/detach)\n\nUsage\n-----\nThe `detach` package contains a context manager called `Detach`. It is used\nwith with `with` statement to fork the current process and execute code in that\nprocess. The child process exits when the context manager exits. The following\nparameters may be passed to `Detach` to change its behavior:\n\n* `stdout` - Redirect child stdout to this stream.\n* `stderr` - Redirect child stderr to this stream.\n* `stdin` - Redirect his stream to child stdin.\n* `close_fds` - Close all file descriptors in the child excluding stdio.\n* `exclude_fds` - Do not close these file descriptors if close_fds is `True`.\n* `daemonize` - Exit the parent process when the context manager exits.\n\nExamples\n--------\n### Simple Fork with STDOUT\n\n import detach, os, sys\n\n with detach.Detach(sys.stdout) as d:\n if d.pid:\n print(\"forked child with pid {}\".format(d.pid))\n else:\n print(\"hello from child process {}\".format(os.getpid()))\n\n### Daemonize \n\n import detach\n from your_app import main\n\n def main():\n \"\"\"Your daemon code here.\"\"\"\n\n with detach.Detach(daemonize=True) as d:\n if d.pid:\n print(\"started process {} in background\".format(pid))\n else:\n main()\n\n### Call External Command\n\n import detach, sys\n pid = detach.call(['bash', '-c', 'echo \"my pid is $$\"'], stdout=sys.stdout)\n print(\"running external command {}\".format(pid)) \n \n\nLicense\n-------\nCopyright (c) 2014 Ryan Bourgeois. This project and all of its contents is\nlicensed under the BSD-derived license as found in the included [LICENSE][1]\nfile.\n\n[1]: https://github.com/bluedragonx/detach/blob/master/LICENSE \"LICENSE\"", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bluedragonx/detach", "keywords": "fork daemon detach", "license": "BSD-derived", "maintainer": null, "maintainer_email": null, "name": "detach", "package_url": "https://pypi.org/project/detach/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/detach/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/bluedragonx/detach" }, "release_url": "https://pypi.org/project/detach/1.0/", "requires_dist": null, "requires_python": null, "summary": "Fork and detach the current processe.", "version": "1.0" }, "last_serial": 1141018, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "2595cd23c0a99a528b4df956b2625653", "sha256": "7c2b67348bcd2b89c2391c2e8ca0bdf1966ea50358a01063daf3f6ae30b00d42" }, "downloads": -1, "filename": "detach-0.1.tar.gz", "has_sig": false, "md5_digest": "2595cd23c0a99a528b4df956b2625653", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2922, "upload_time": "2014-06-28T06:48:56", "url": "https://files.pythonhosted.org/packages/26/46/9ea500494644cc5d6309e81b1755e92f86e18e5542b684e0093b860ede5b/detach-0.1.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "321bb1b6e8581a99689ee09bf88401cf", "sha256": "95b7164735506b9f12181c717d74289cea7f300cb5e1ec1970a3f9f45860683f" }, "downloads": -1, "filename": "detach-1.0.tar.gz", "has_sig": false, "md5_digest": "321bb1b6e8581a99689ee09bf88401cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3365, "upload_time": "2014-06-28T23:48:00", "url": "https://files.pythonhosted.org/packages/83/4c/6028198445fe35f6ba7a12bca5ec19d8273d2b259b50e8ea0564348a13c2/detach-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "321bb1b6e8581a99689ee09bf88401cf", "sha256": "95b7164735506b9f12181c717d74289cea7f300cb5e1ec1970a3f9f45860683f" }, "downloads": -1, "filename": "detach-1.0.tar.gz", "has_sig": false, "md5_digest": "321bb1b6e8581a99689ee09bf88401cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3365, "upload_time": "2014-06-28T23:48:00", "url": "https://files.pythonhosted.org/packages/83/4c/6028198445fe35f6ba7a12bca5ec19d8273d2b259b50e8ea0564348a13c2/detach-1.0.tar.gz" } ] }