Skip to content

Instantly share code, notes, and snippets.

@BibMartin
Created July 9, 2015 13:31
Show Gist options
  • Select an option

  • Save BibMartin/f1833f134024ed276f4b to your computer and use it in GitHub Desktop.

Select an option

Save BibMartin/f1833f134024ed276f4b to your computer and use it in GitHub Desktop.
Watch and kill queries with pymongo
import pymongo
connection = pymongo.MongoClient()
# get running operations
list(connection.admin["$cmd.sys.inprog"].find())
# kill an operation by id
op_id = 123456
connection.admin["$cmd.sys.killop"].find_one({'op':op_id})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment