Permalink
Browse files

Allow connections to be pickled.

  • Loading branch information...
1 parent fd290e9 commit 4554b9f0ca7bff57cb2752bcd9bba77a8b7dd438 @garnaat garnaat committed Sep 5, 2012
Showing with 21 additions and 0 deletions.
  1. +11 −0 boto/auth.py
  2. +10 −0 boto/connection.py
View
@@ -37,6 +37,7 @@
import urllib
import time
import datetime
+import copy
from email.utils import formatdate
from boto.auth_handler import AuthHandler
@@ -103,6 +104,16 @@ def sign_string(self, string_to_sign):
hmac.update(string_to_sign)
return base64.encodestring(hmac.digest()).strip()
+ def __getstate__(self):
+ pickled_dict = copy.copy(self.__dict__)
+ del pickled_dict['_hmac']
+ del pickled_dict['_hmac_256']
+ return pickled_dict
+
+ def __setstate__(self, dct):
+ self.__dict__ = dct
+ self.update_provider(self._provider)
+
class AnonAuthHandler(AuthHandler, HmacKeys):
"""
View
@@ -55,6 +55,7 @@
import time
import urllib, urlparse
import xml.sax
+import copy
import auth
import auth_handler
@@ -237,6 +238,15 @@ def __init__(self):
config.getfloat('Boto', 'connection_stale_duration',
ConnectionPool.STALE_DURATION)
+ def __getstate__(self):
+ pickled_dict = copy.copy(self.__dict__)
+ pickled_dict['host_to_pool'] = {}
+ del pickled_dict['mutex']
+ return pickled_dict
+
+ def __setstate__(self, dct):
+ self.__init__()
+
def size(self):
"""
Returns the number of connections in the pool.

0 comments on commit 4554b9f

Please sign in to comment.