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
5a5c22be
Commit
5a5c22be
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: New IdleLoop.synchronous context manager which sets/restores the neverQueue
flag.
parent
758a7a70
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/idle.py
+20
-3
20 additions, 3 deletions
fsl/utils/idle.py
with
20 additions
and
3 deletions
fsl/utils/idle.py
+
20
−
3
View file @
5a5c22be
...
...
@@ -79,6 +79,7 @@ import atexit
import
logging
import
functools
import
threading
from
contextlib
import
contextmanager
from
collections
import
abc
try
:
import
queue
...
...
@@ -225,15 +226,31 @@ class IdleLoop(object):
@property
def
neverQueue
(
self
):
"""
If ``True``, tasks passed to :meth:`idle` will never be queued, and
instead will always be executed directly/synchonously.
instead will always be executed directly/synchonously. See also the
:meth:`synchronous` context manager.
"""
return
self
.
__neverQueue
@neverQueue.setter
def
neverQueue
(
self
,
al
low
):
def
neverQueue
(
self
,
v
al
):
"""
Update the ``neverQueue`` flag.
"""
self
.
__neverQueue
=
allow
self
.
__neverQueue
=
val
@contextmanager
def
synchronous
(
self
):
"""
Context manager which can be used to tenporarily set :meth:`neverQueue` to
``True``, restoring its previous value afterwards.
"""
oldval
=
self
.
__neverQueue
self
.
__neverQueue
=
True
try
:
yield
finally
:
self
.
__neverQueue
=
oldval
def
reset
(
self
):
...
...
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