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

Avoid import deadlocks in test suite

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.7
    • Affects Version/s: None
    • Component/s: Tests
    • None

      Importing the "test" module automatically initializes a global ClientContext object, and the ClientContext constructor connects to the server and discovers its configuration, all while Python is holding the import lock. This makes the test module prone to deadlock, either in elaborate scenarios like Motor's synchrotest (MOTOR-226) or in more ordinary situations as we develop PyMongo and its test runner.

      Let's do less work at import-time in the "test" module. Don't connect to the server in ClientContext's constructor; defer that until someone calls a new method named ClientContext.init(). We can make that method idempotent and call it from IntegrationTest.setUpClass() to ensure it's always run exactly once before tests start. Furthermore, even ClientContext.init() can do less work, its use of getCmdLineOpts to discover auth configuration is outdated.

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

              Created:
              Updated:
              Resolved: