PythonScanClient / PyScanClient

Python Client for CS-Studio Scan Service
Eclipse Public License 1.0
3 stars 4 forks source link

ScanClient connection close() and exception handling #8

Closed kasemir closed 9 years ago

kasemir commented 9 years ago

ScanClient has a few sections like this:

try:
   conn = urllib2.urlopen
   .. do_something ..
   conn.close()
except Exception as ex:
            raise ex

It's great to think about closing the connection, and also to handle exceptions. In this example, however, except simply raises the original exception, it doesn't add anything. If .. do_something .. fails, close() is not called.

Better:

conn = urllib2.urlopen
try:
   .. do_something ..
finally:
   conn.close()
ksdj commented 9 years ago

Ah! Yes it is! I will change this.