@@ -220,6 +220,10 @@ def __init__(
220220           returns immediately and launches the connection process on 
221221           background threads. 
222222
223+            Therefore the ``alive`` method is removed since it no longer 
224+            provides meaningful information; even if the client is disconnected, 
225+            it may discover a server in time to fulfill the next operation. 
226+ 
223227           In PyMongo 2.x, :class:`~pymongo.MongoClient` accepted a list of 
224228           standalone MongoDB servers and used the first it could connect to:: 
225229
@@ -657,39 +661,6 @@ def close(self):
657661        """ 
658662        self .disconnect ()
659663
660-     def  alive (self ):
661-         """Return ``False`` if there has been an error communicating with the 
662-         server, else ``True``. 
663- 
664-         This method attempts to check the status of the server (the standalone, 
665-         replica set primary, or the mongos currently in use) with minimal I/O. 
666-         Retrieves a socket from the pool and checks whether calling `select`_ 
667-         on it raises an error. If there are currently no idle sockets, 
668-         :meth:`alive` attempts to actually connect to the server. 
669- 
670-         A more certain way to determine server availability is:: 
671- 
672-             client.admin.command('ping') 
673- 
674-         .. _select: http://docs.python.org/2/library/select.html#select.select 
675-         """ 
676-         # In the common case, a socket is available and was used recently, so 
677-         # calling select() on it is a reasonable attempt to see if the OS has 
678-         # reported an error. 
679-         try :
680-             # TODO: Mongos pinning. 
681-             server  =  self ._topology .select_server (
682-                 writable_server_selector ,
683-                 server_wait_time = 0 )
684- 
685-             # Avoid race when other threads log in or out. 
686-             all_credentials  =  self .__all_credentials .copy ()
687-             with  server .get_socket (all_credentials ) as  sock_info :
688-                 return  not  socket_closed (sock_info .sock )
689- 
690-         except  (socket .error , ConnectionFailure ):
691-             return  False 
692- 
693664    def  set_cursor_manager (self , manager_class ):
694665        """Set this client's cursor manager. 
695666
0 commit comments