[Tutor] tuples and mysqldb tables

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Sep 19 05:03:13 CEST 2005

> def run(self):
>     try:
>         ss = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>         ss.connect((ip, port_counter))
>         print "%s | %d OPEN" % (ip, port_counter)
>         ss.close()
>     except: pass

Hi Ed,

Yikes.  Don't do that.  *grin*

By "that", I mean setting the exception handler here to do nothing.
Exception handling shouldn't abused to silence errors like that, at least,
not wholesale like that.  At the very least, while we're debugging this,
import the 'traceback' module and at least give a heads up, like this:


Once this is in place, expect to see errors.  I know what you meant to do:
you wanted to ignore network errors, so try to make the exception handler
a little more specific in the exceptions it's trying to silence.

The problem here is that the handler has been inadvertantely silencing a
legitimate NameError.  From casual inspection, it's not clear what
'port_counter' is.  I suspect you want to add that as part of the thread's
state, in which case consider adding it within your thread's __init__

> def scan(ip, begin, end):
>     for port_counter in range(begin, end):
>         while threading < MAX_THREADS:
>         scanThread().start()
> # end function -------------------

Ok, I definitely suspect port_counter now as the culprit here.  Make sure
you create each thread with port_counter as a part of each thread's state.

[Aside: are you trying to a port scanner in the style that Jacob Matthews
wrote about here?


Just curious.]

Good luck to you!

More information about the Tutor mailing list