Open iogakos opened 6 years ago
Hi @wojcikstefan, I'd like to have your input on this. I've always wondered why we were exposing register_connection
(as opposed to just exposing connect
), the only valuable reason that I see is to allow users to register the settings and delay the actual creation of the pymongo connections until they are actually required (which they can only do by calling get_connection()
today, as shown by this issue). Are there other use cases?
Exposing register_connection
brings a few potential bugs like this one due to the de-synchronization of the different globals that maintain the connections (_connections, _connection_details, etc)
I believe it will be less confusing to only expose connect()
, let me know what you think
@bagerard just a note, for something like a test situation, the app code may call connect()
and disconnect()
multiple times, register_connection()
lets me set the default prior to other code being called. Hope it helps.
Hi,
I use
register_connection()
to register the default connection settings andconnect()
to establish a connection afterwards. When callingconnect()
without analias
, I would expect to connect using the default settings previously defined withregister_connection()
, thoughconnect()
ignores the default alias and falls back to the sane defaults:Note, the host used when registering the default alias and the host of the established client are different.
connect()
ends up overwriting the default connection settings.get_connection()
seems to respect the default connection settings instead:I am a bit confused whether this is an expected behaviour or not. My proposed fix is changing
connect()
to look at_connection_settings
instead of_connections
before registering a connection which doesn't seem to break any of the existing tests.