Skip to content

Commit 9821912

Browse files
committed
Use disable_sigint instead of sigatomic_(begin|end)
1 parent 0b2dc20 commit 9821912

File tree

4 files changed

+4
-23
lines changed

4 files changed

+4
-23
lines changed

src/PyCall.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ if isdefined(Base, :hasproperty) # Julia 1.2
2424
import Base: hasproperty
2525
end
2626

27-
# Python C API is not interrupt-safe. In principle, we should
28-
# use sigatomic for every ccall to the Python library, but this
29-
# should really be fixed in Julia (#2622). However, we will
30-
# use the sigatomic_begin/end functions to protect pycall and
31-
# similar long-running (or potentially long-running) code.
32-
import Base: sigatomic_begin, sigatomic_end
33-
3427
import Conda
3528
import MacroTools # because of issue #270
3629
import Base.Iterators: filter

src/pyeval.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ pynamespace(m::Module) =
3131
# and a current "file name" to use for stack traces
3232
function pyeval_(s::AbstractString, globals=pynamespace(Main), locals=pynamespace(Main),
3333
input_type=Py_eval_input, fname="PyCall")
34-
sigatomic_begin()
35-
try
34+
disable_sigint() do
3635
o = PyObject(@pycheckn ccall((@pysym :Py_CompileString), PyPtr,
3736
(Cstring, Cstring, Cint),
3837
s, fname, input_type))
3938
return PyObject(@pycheckn ccall((@pysym :PyEval_EvalCode),
4039
PyPtr, (PyPtr, PyPtr, PyPtr),
4140
o, globals, locals))
42-
finally
43-
sigatomic_end()
4441
end
4542
end
4643

src/pyfncall.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@ Sets `ret.o` to the result of the call, and returns `ret::PyObject`.
3939
"""
4040
function __pycall!(ret::PyObject, pyargsptr::PyPtr, o::Union{PyObject,PyPtr},
4141
kw::Union{Ptr{Cvoid}, PyObject})
42-
sigatomic_begin()
43-
try
42+
disable_sigint() do
4443
retptr = @pycheckn ccall((@pysym :PyObject_Call), PyPtr, (PyPtr,PyPtr,PyPtr), o,
4544
pyargsptr, kw)
4645
pydecref_(ret)
4746
setfield!(ret, :o, retptr)
48-
finally
49-
sigatomic_end()
5047
end
5148
return ret #::PyObject
5249
end

src/pyiterator.jl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55

66
Base.IteratorSize(::Type{PyObject}) = Base.SizeUnknown()
77
function _start(po::PyObject)
8-
sigatomic_begin()
9-
try
8+
disable_sigint() do
109
o = PyObject(@pycheckn ccall((@pysym :PyObject_GetIter), PyPtr, (PyPtr,), po))
1110
nxt = PyObject(@pycheck ccall((@pysym :PyIter_Next), PyPtr, (PyPtr,), o))
1211

1312
return (nxt,o)
14-
finally
15-
sigatomic_end()
1613
end
1714
end
1815

@@ -76,12 +73,9 @@ _start(piter::PyIterator) = _start(piter.o)
7673

7774
function Base.iterate(piter::PyIterator{T}, s=_start(piter)) where {T}
7875
ispynull(s[1]) && return nothing
79-
sigatomic_begin()
80-
try
76+
disable_sigint() do
8177
nxt = PyObject(@pycheck ccall((@pysym :PyIter_Next), PyPtr, (PyPtr,), s[2]))
8278
return (convert(T,s[1]), (nxt, s[2]))
83-
finally
84-
sigatomic_end()
8579
end
8680
end
8781
function Base.iterate(po::PyObject, s=_start(po))

0 commit comments

Comments
 (0)