<p>I've written a simple multi-threaded game server in python that creates a new thread for each client connection.  I'm finding that every now and then, the server will crash because of a broken-pipe/SIGPIPE error.  I'm pretty sure it is happening when the program tries to send a response back to a client that is no longer present.</p>

<p>What is a good way to deal with this?  My preferred resolution would simply close the server-side connection to the client and move on, rather than exit the entire program.</p>

<p>PS: <a href="https://stackoverflow.com/questions/108183/how-to-prevent-sigpipes-or-handle-them-properly">This</a> question/answer deals with the problem in a generic way; how specifically should I solve it?</p>

Read up on the try: statement.
```
```
try:
    # do something
except socket.error, e:
    # A socket error
except IOError, e:
    if e.errno == errno.EPIPE:
        # EPIPE error
    else:
        # Other error
```
```