{ "info": { "author": "Benjamin Wohlwend", "author_email": "piquadrat@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "# namedthreads\n\n![](https://api.travis-ci.org/beniwohli/namedthreads.svg?branch=master)\n\nThis is a hack to propagate thread names set in Python to the system.\n\n*WARNING*: This is only meant for testing/debugging purposes. Do *NOT* run in production.\n\n## The problem\n\nYou can name threads in Python like so:\n\n import threading\n\n my_thread = threading.Thread(target=my_func, name=\"my-thread\")\n\nBut when running `ps`, `top` and similar, you'll notice that the thread name isn't visible in these tools,\nmaking threading bugs somewhat harder to debug.\n\n## The solution\n\nA comment in [bpo-15500](https://bugs.python.org/issue15500#msg230736) lines out a monkeypatch that uses `ctypes` to set the name using `libpthread.pthread_setname_np`.\nWhile this works beautifully, it hasn't been included in core python due to compatibility reasons. This module packages the monkeypatch in an easy to install package.\n\n| *Before* | *After*\t |\n|--------------------------------------------|-------------------------------------------|\n|![](http://s.woh.li/before_namedthreads.png)|![](http://s.woh.li/after_namedthreads.png)|\n\n\n## Usage\n\n### Install\n\n pip install namedthreads\n\n### Manual patching\n\nRun this as early as possible in your code:\n\n import namedthreads\n namedthreads.patch()\n\n### Automatic patching\n\nInspired by Graham Dumpleton's [autowrapt](https://github.com/GrahamDumpleton/autowrapt), this module can\nbe activated automatically. Due to the [hacky nature](http://blog.dscpl.com.au/2015/04/automatic-patching-of-python.html)\nof this approach, it is guarded by checking the presence of an environment variable, `NAMEDTHREADS`.\nAutomatic patching is only activated if this environment variable is set\n\n NAMEDTHREADS=1 python myscript.py", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/beniwohli/namedthreads", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "namedthreads", "package_url": "https://pypi.org/project/namedthreads/", "platform": "OS Independent", "project_url": "https://pypi.org/project/namedthreads/", "project_urls": { "Homepage": "https://github.com/beniwohli/namedthreads" }, "release_url": "https://pypi.org/project/namedthreads/1.0/", "requires_dist": null, "requires_python": "", "summary": "Patch to propagate Python thread names to system thread names", "version": "1.0" }, "last_serial": 5117305, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "eeae61f33ce208f86047d976b01c0dcd", "sha256": "f8dea2d2a9b31b2d558634eef2a1f3f09726897bfdb03bcc56439885271f01c8" }, "downloads": -1, "filename": "namedthreads-1.0.tar.gz", "has_sig": false, "md5_digest": "eeae61f33ce208f86047d976b01c0dcd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3744, "upload_time": "2019-04-09T07:20:16", "url": "https://files.pythonhosted.org/packages/8b/ad/52189fe39e5fa67c737832e1bd9320822b6e7e71adaeb8c4a2fcd5a6135b/namedthreads-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "eeae61f33ce208f86047d976b01c0dcd", "sha256": "f8dea2d2a9b31b2d558634eef2a1f3f09726897bfdb03bcc56439885271f01c8" }, "downloads": -1, "filename": "namedthreads-1.0.tar.gz", "has_sig": false, "md5_digest": "eeae61f33ce208f86047d976b01c0dcd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3744, "upload_time": "2019-04-09T07:20:16", "url": "https://files.pythonhosted.org/packages/8b/ad/52189fe39e5fa67c737832e1bd9320822b6e7e71adaeb8c4a2fcd5a6135b/namedthreads-1.0.tar.gz" } ] }