flymg
flymg

Reputation: 617

Pymongo abandoned "pymongo_kill_cursors_thread" after client exit

i have a Python app, which is running jobs in separated threads. Some workerjobs implement pymongo for a database connection.

class Job(Thread):
     ...
     self.client = MongoClient()

Every job has a finish method, where

self.client.close()

is called, when the job is going to terminate. Assumably, this should end all associated threads, but one single thread of every job stays alive: pymongo_kill_cursors_thread

As i am launching multiple jobs, and finishing them, these pymongo_kill_cursors_threads never die and i got them in the hundreds after a short time, here is one example, after a test job finished:

Result of threading.enumerate()

I don't know why the close() method of pymongo doesn't clean up properly, nor if this is a pymongo or mongodb issue.

Trying

self.client._kill_cursors_executor._thread.join(1)

has no effect, i think its because of the locked state of the thread and the fact, that it is daemon.

Any ideas appreciated. Thank you very much.

Using "PyMongo", version: "3.5.1" with Python 3.6.1 and MongoDB running in the official docker image

Upvotes: 4

Views: 909

Answers (1)

A. Jesse Jiryu Davis
A. Jesse Jiryu Davis

Reputation: 24007

Sounds like it could be a bug, although it requires additional diagnosis. Please open a ticket in the PYTHON project at jira.mongodb.org and provide a complete code example that we can run on our computers that reproduces the error you see: https://stackoverflow.com/help/mcve

Thanks!

Upvotes: 2

Related Questions