Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-560

TypeError or InvalidOperation when multiple threads trigger lazy connection

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7
    • Affects Version/s: 2.6
    • Component/s: None
    • None

      If MongoClient and MongoReplicaSetClient are initialized with _connect=False and many threads attempt inserts at once, some may receive a TypeError:

        File "/Users/emptysquare/.virtualenvs/official/mongo-python-driver/pymongo/collection.py", line 362, in insert
          self.database.connection)
      TypeError: an integer is required
      

      Alternatively, MongoReplicaSetClient may throw InvalidOperation instead:

        File "/Users/emptysquare/.virtualenvs/official/mongo-python-driver/pymongo/collection.py", line 347, in insert
          self.database.connection._ensure_connected(True)
        File "/Users/emptysquare/.virtualenvs/official/mongo-python-driver/pymongo/mongo_replica_set_client.py", line 1243, in _ensure_connected
          self.__schedule_refresh(sync)
        File "/Users/emptysquare/.virtualenvs/official/mongo-python-driver/pymongo/mongo_replica_set_client.py", line 1067, in __schedule_refresh
          self.__monitor.schedule_refresh()
        File "/Users/emptysquare/.virtualenvs/official/mongo-python-driver/pymongo/mongo_replica_set_client.py", line 295, in schedule_refresh
          "Monitor thread is dead: Perhaps started before a fork?")
      InvalidOperation: Monitor thread is dead: Perhaps started before a fork?
      

      These bugs are a consequence of PYTHON-516, which made _connect=False work more correctly than before, and related to PYTHON-414 which requires a client to be connected before using the max_message_size attribute in insert().

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: