Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
f6c74748
Commit
f6c74748
authored
3 weeks ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
BF: Notifier.notify() could raise an exception if a callback function was GC'd
parent
eae17115
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/notifier.py
+13
-7
13 additions, 7 deletions
fsl/utils/notifier.py
with
13 additions
and
7 deletions
fsl/utils/notifier.py
+
13
−
7
View file @
f6c74748
...
...
@@ -66,7 +66,12 @@ class _Listener:
positional arguments - see :meth:`Notifier.register` for details.
"""
func
=
self
.
callback
func
=
self
.
callback
# the function may have been GC'd
if
func
is
None
:
return
False
spec
=
inspect
.
signature
(
func
)
posargs
=
0
varargs
=
False
...
...
@@ -377,9 +382,6 @@ class Notifier:
callback
=
listener
.
callback
name
=
listener
.
name
if
listener
.
expectsArguments
:
args
=
(
self
,
topic
,
value
)
else
:
args
=
()
# The callback, or the owner of the
# callback function may have been
# gc'd - remove it if this is the case.
...
...
@@ -387,12 +389,16 @@ class Notifier:
log
.
debug
(
'
Listener %s has been gc
\'
d -
'
'
removing from list
'
,
name
)
self
.
__listeners
[
listener
.
topic
].
pop
(
name
)
continue
el
if
not
listener
.
enabled
:
if
not
listener
.
enabled
:
continue
elif
listener
.
runOnIdle
:
idle
.
idle
(
callback
,
*
args
)
else
:
callback
(
*
args
)
if
listener
.
expectsArguments
:
args
=
(
self
,
topic
,
value
)
else
:
args
=
()
if
listener
.
runOnIdle
:
idle
.
idle
(
callback
,
*
args
)
else
:
callback
(
*
args
)
def
__getListeners
(
self
,
topic
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment