In PYTHON-577 we started raising UserWarning when a call to db.command ignores the user specified read preference and re-directs the command to the primary. This happens for any command not listed in read_preferences.secondary_ok_commands.
Unfortunately a number of internal calls to db.command, and helpers for commands that don't obey read preference, are causing UserWarning to be raised when db.read_preference is set to anything other than PRIMARY.
A few things need to be fixed:
- Helpers that don't obey read preference should explicitly pass ReadPreference.PRIMARY to db.command.
- Internal calls for non-obedient commands should do the same (e.g. md5sum in gridfs)
- The test suite should be fixed so that problems like this aren't obscured in the future.