How to raise a socket "104 connection reset by peer error"

Andrew Berg bahamutzero8825 at gmail.com
Tue May 21 11:49:31 EDT 2013


On 2013.05.21 10:26, loial wrote:
> For testing purposes I want my code to raise a socket "connection reset by peer" error, so that I can test how I handle it, but I am not sure how to raise the error.
Arbitrary exceptions can be raised with the raise keyword. In Python 3.3, that exact error got its own builtin exception:
http://docs.python.org/3.3/tutorial/errors.html#raising-exceptions
http://docs.python.org/3.3/library/exceptions.html#ConnectionResetError

In earlier versions of Python, you will have to raise OSError and set its errno attribute.

-- 
CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1



More information about the Python-list mailing list