Commit bdcfff98 by willmcgugan

Failed attempts at a fix for Py2.7

parent 4e1dbdd7
...@@ -137,9 +137,7 @@ class RPCFS(FS): ...@@ -137,9 +137,7 @@ class RPCFS(FS):
return state return state
def __setstate__(self, state): def __setstate__(self, state):
for (k,v) in state.iteritems(): super(RPCFS, self).__setstate__(state)
self.__dict__[k] = v
self._lock = threading.RLock()
self.proxy = self._make_proxy() self.proxy = self._make_proxy()
def encode_path(self, path): def encode_path(self, path):
......
...@@ -25,6 +25,9 @@ class WrongHostKeyError(RemoteConnectionError): ...@@ -25,6 +25,9 @@ class WrongHostKeyError(RemoteConnectionError):
# SFTPClient appears to not be thread-safe, so we use an instance per thread # SFTPClient appears to not be thread-safe, so we use an instance per thread
if hasattr(threading, "local"): if hasattr(threading, "local"):
thread_local = threading.local thread_local = threading.local
#class TL(object):
# pass
#thread_local = TL
else: else:
class thread_local(object): class thread_local(object):
def __init__(self): def __init__(self):
...@@ -207,24 +210,33 @@ class SFTPFS(FS): ...@@ -207,24 +210,33 @@ class SFTPFS(FS):
return state return state
def __setstate__(self,state): def __setstate__(self,state):
for (k,v) in state.iteritems(): super(SFTPFS, self).__setstate__(state)
self.__dict__[k] = v #for (k,v) in state.iteritems():
self._lock = threading.RLock() # self.__dict__[k] = v
#self._lock = threading.RLock()
self._tlocal = thread_local() self._tlocal = thread_local()
if self._owns_transport: if self._owns_transport:
self._transport = paramiko.Transport(self._transport) self._transport = paramiko.Transport(self._transport)
self._transport.connect(**self._credentials) self._transport.connect(**self._credentials)
@property @property
@synchronize
def client(self): def client(self):
try: client = getattr(self._tlocal, 'client', None)
return self._tlocal.client if client is None:
except AttributeError: if self._transport is None:
#if self._transport is None: return self._client
# return self._client
client = paramiko.SFTPClient.from_transport(self._transport) client = paramiko.SFTPClient.from_transport(self._transport)
self._tlocal.client = client self._tlocal.client = client
return client return client
# try:
# return self._tlocal.client
# except AttributeError:
# #if self._transport is None:
# # return self._client
# client = paramiko.SFTPClient.from_transport(self._transport)
# self._tlocal.client = client
# return client
@synchronize @synchronize
def close(self): def close(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment