summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTal Einat <tal.einat@socialcodeinc.com>2017-07-27 13:03:22 +0300
committerTal Einat <tal.einat@socialcodeinc.com>2017-07-27 13:03:22 +0300
commit3eede93ee3c6aad5c7c7f8d9514f0d2a4be7d226 (patch)
treeb7b39d1be5dbd409645809e7edaea0e0e3248005
parentdab9a704e61154dac870cade13283881955cf366 (diff)
downloadpycurl-3eede93ee3c6aad5c7c7f8d9514f0d2a4be7d226.tar.gz
fix and standardize ignoring of SIGPIPE in examples
-rw-r--r--examples/retriever-multi.py5
-rw-r--r--examples/retriever.py4
-rw-r--r--examples/tests/test_gtk.py4
-rw-r--r--examples/xmlrpc_curl.py5
-rw-r--r--python/curl/__init__.py5
5 files changed, 18 insertions, 5 deletions
diff --git a/examples/retriever-multi.py b/examples/retriever-multi.py
index 0a49598..8f5bef0 100644
--- a/examples/retriever-multi.py
+++ b/examples/retriever-multi.py
@@ -14,9 +14,12 @@ import pycurl
# the libcurl tutorial for more info.
try:
import signal
- signal.signal(signal.SIGPIPE, signal.SIG_IGN)
+ from signal import SIGPIPE, SIG_IGN
except ImportError:
pass
+else:
+ signal.signal(SIGPIPE, SIG_IGN)
+
# Get args
diff --git a/examples/retriever.py b/examples/retriever.py
index c8fb842..ff939c0 100644
--- a/examples/retriever.py
+++ b/examples/retriever.py
@@ -18,9 +18,11 @@ import pycurl
# the libcurl tutorial for more info.
try:
import signal
- signal.signal(signal.SIGPIPE, signal.SIG_IGN)
+ from signal import SIGPIPE, SIG_IGN
except ImportError:
pass
+else:
+ signal.signal(SIGPIPE, SIG_IGN)
# Get args
diff --git a/examples/tests/test_gtk.py b/examples/tests/test_gtk.py
index fa4e868..fdc3a2f 100644
--- a/examples/tests/test_gtk.py
+++ b/examples/tests/test_gtk.py
@@ -12,9 +12,11 @@ import gtk
# the libcurl tutorial for more info.
try:
import signal
- signal.signal(signal.SIGPIPE, signal.SIG_IGN)
+ from signal import SIGPIPE, SIG_IGN
except ImportError:
pass
+else:
+ signal.signal(SIGPIPE, SIG_IGN)
class ProgressBar:
diff --git a/examples/xmlrpc_curl.py b/examples/xmlrpc_curl.py
index 9b78daa..653d6ce 100644
--- a/examples/xmlrpc_curl.py
+++ b/examples/xmlrpc_curl.py
@@ -6,9 +6,12 @@
# the libcurl tutorial for more info.
try:
import signal
- signal.signal(signal.SIGPIPE, signal.SIG_IGN)
+ from signal import SIGPIPE, SIG_IGN
except ImportError:
pass
+else:
+ signal.signal(SIGPIPE, SIG_IGN)
+
try:
from cStringIO import StringIO
except ImportError:
diff --git a/python/curl/__init__.py b/python/curl/__init__.py
index f92687d..9fb9171 100644
--- a/python/curl/__init__.py
+++ b/python/curl/__init__.py
@@ -21,12 +21,15 @@ else:
except ImportError:
from StringIO import StringIO as BytesIO
+# We should ignore SIGPIPE when using pycurl.NOSIGNAL - see
+# the libcurl tutorial for more info.
try:
import signal
from signal import SIGPIPE, SIG_IGN
- signal.signal(SIGPIPE, SIG_IGN)
except ImportError:
pass
+else:
+ signal.signal(SIGPIPE, SIG_IGN)
class Curl: