Anonymous avatar Anonymous committed edaad09

fixed error in async replication function, and set a default timeout of 120 seconds for replication

Comments (0)

Files changed (1)

         return self._http_get('/_all_dbs')
 
     def info_db(self):
-        '''Returns info about the database'''
+        '''Get info about the database'''
         return self._http_get(''.join(['/', self.db_name, '/']))
         
     def pull_db(self, source, create_target=False):
-        '''Replicate from a source database to current (target) db'''
+        '''Replicate changes from a source database to current (target) db'''
         body = json_encode({'source': source, 'target': self.db_name, 'create_target': create_target})
-        return self._http_post('/_replicate', body)
+        return self._http_post('/_replicate', body, connect_timeout=120.0, request_timeout=120.0)
 
     def uuids(self, count=1):
         if count > 1:
         
           group_level=<number>
           
-        
         Use the reduce function of the view. It defaults to true, if a reduce
         function is defined and to false otherwise.
           reduce=true
 
         return self._parse_response(resp, decode=decode)
 
-    def _http_post(self, uri, body, doc=None):
+    def _http_post(self, uri, body, doc=None, **kwargs):
         headers = {'Accept': 'application/json',
                    'Content-Type': 'application/json'}
         r = httpclient.HTTPRequest(self.couch_url + uri, method='POST',
-                                   headers=headers,
-                                   body=body, use_gzip=False)
+                                   headers=headers, body=body,
+                                   use_gzip=False, **kwargs)
         try:
             resp = self.client.fetch(r)
         except httpclient.HTTPError, e:
         self._http_get('/_all_dbs', callback=callback)
 
     def info_db(self, callback=None):
-        '''Returns info about the database'''
+        '''Get info about the database'''
         self._http_get(''.join(['/', self.db_name, '/']), callback=callback)
 
-    def pull_db(self, source, create_target=False):
-        '''Replicate from a source database to current (target) db'''
+    def pull_db(self, source, callback=None, create_target=False):
+        '''Replicate changes from a source database to current (target) db'''
         body = json_encode({'source': source, 'target': self.db_name, 'create_target': create_target})
-        return self._http_post('/_replicate', body, callback=callback)
+        self._http_post('/_replicate', body, callback=callback, connect_timeout=120.0, request_timeout=120.0)
 
     def uuids(self, count=1, callback=None):
         def got_uuids(result):
-            if not callback:
-                return 
-            if isinstance(result, Exception):
-                callback(result)
-            else:
-                callback(result['uuids'])
+            if callback:
+                if isinstance(result, Exception):
+                    callback(result)
+                else:
+                    callback(result['uuids'])
         if count > 1:
             q = ''.join(['?count=', str(count)])
         else:
         
           group_level=<number>
           
-        
         Use the reduce function of the view. It defaults to true, if a reduce
         function is defined and to false otherwise.
           reduce=true
         cb = lambda resp: self._http_callback(resp, callback, decode=decode)
         self.client.fetch(r, cb)
 
-    def _http_post(self, uri, body, doc=None, callback=None):
+    def _http_post(self, uri, body, doc=None, callback=None, **kwargs):
         headers = {'Accept': 'application/json',
                    'Content-Type': 'application/json'}
         r = httpclient.HTTPRequest(self.couch_url + uri, method='POST',
-                                   headers=headers,
-                                   body=body, use_gzip=False)
+                                   headers=headers, body=body,
+                                   use_gzip=False, **kwargs)
         self.client.fetch(r, lambda resp: self._http_callback(resp, callback,
                                                               doc=doc))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.