benoitc/restkit — Issue #81: local variable 'sck' referenced before assignment
Author: stefankoegl
Created: 2011-11-30 07:35:39+00:00
State: open

I use restkit master branch (through couchdbkit) and from time to time I get the following error

````python
File "/usr/local/lib/python2.6/dist-packages/couchdbkit-0.5.5-py2.6.egg/couchdbkit/client.py", line 1006, in __nonzero__
return bool(len(self))

File "/usr/local/lib/python2.6/dist-packages/couchdbkit-0.5.5-py2.6.egg/couchdbkit/client.py", line 1003, in __len__
return self.count()

File "/usr/local/lib/python2.6/dist-packages/couchdbkit-0.5.5-py2.6.egg/couchdbkit/client.py", line 937, in count
self._fetch_if_needed()

File "/usr/local/lib/python2.6/dist-packages/couchdbkit-0.5.5-py2.6.egg/couchdbkit/client.py", line 968, in _fetch_if_needed
self.fetch()

File "/usr/local/lib/python2.6/dist-packages/couchdbkit-0.5.5-py2.6.egg/couchdbkit/client.py", line 950, in fetch
self._result_cache = self.view._exec(**self.params).json_body

File "/usr/local/lib/python2.6/dist-packages/couchdbkit-0.5.5-py2.6.egg/couchdbkit/client.py", line 1038, in _exec
return self._db.res.get(self.view_path, **params)

File "/usr/local/lib/python2.6/dist-packages/restkit-3.3.0-py2.6.egg/restkit/resource.py", line 114, in get
params_dict=params_dict, **params)

File "/usr/local/lib/python2.6/dist-packages/couchdbkit-0.5.5-py2.6.egg/couchdbkit/resource.py", line 111, in request
payload=payload, headers=headers, **params)

File "/usr/local/lib/python2.6/dist-packages/restkit-3.3.0-py2.6.egg/restkit/resource.py", line 190, in request
headers=self.make_headers(headers))

File "/usr/local/lib/python2.6/dist-packages/restkit-3.3.0-py2.6.egg/restkit/client.py", line 458, in request
return self.perform(request)

File "/usr/local/lib/python2.6/dist-packages/restkit-3.3.0-py2.6.egg/restkit/client.py", line 333, in perform
connection = self.get_connection(request)

File "/usr/local/lib/python2.6/dist-packages/restkit-3.3.0-py2.6.egg/restkit/client.py", line 227, in get_connection
sck = self.connect(addr, is_ssl)

File "/usr/local/lib/python2.6/dist-packages/restkit-3.3.0-py2.6.egg/restkit/client.py", line 210, in connect
close(sck)

UnboundLocalError: local variable 'sck' referenced before assignment
````

It seems that this error is related to timeouts or other "lower" problems, but I could not confirm this yet.