We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb334ca commit bf2c3ebCopy full SHA for bf2c3eb
src/PyCall.jl
@@ -84,15 +84,13 @@ end
84
const PYDECREF_LOCK = ReentrantLock()
85
86
function _pydecref_locked(po::PyObject)
87
- if !islocked(PYDECREF_LOCK)
88
- # If available, we lock and decref
89
- lock(PYDECREF_LOCK) do
90
- pydecref_(po)
91
- end
92
- else
93
- # Add back to queue to be decref'd later
94
- finalizer(_pydecref_locked, po)
95
+ # If available, we lock and decref
+ if !islocked(PYDECREF_LOCK) &&
+ trylock(() -> pydecref_(po), PYDECREF_LOCK) &&
+ return nothing
+
+ # Add back to queue to be decref'd later
+ finalizer(_pydecref_locked, po)
96
return nothing
97
end
98
0 commit comments