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
0deb8e7d
Commit
0deb8e7d
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix in async.idle handling of alwaysQueue option. New function idleReset,
which is primarily for testing.
parent
ba57f116
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/async.py
+31
-3
31 additions, 3 deletions
fsl/utils/async.py
with
31 additions
and
3 deletions
fsl/utils/async.py
+
31
−
3
View file @
0deb8e7d
...
@@ -23,6 +23,7 @@ Idle tasks
...
@@ -23,6 +23,7 @@ Idle tasks
idleWhen
idleWhen
inIdle
inIdle
cancelIdle
cancelIdle
idleReset
getIdleTimeout
getIdleTimeout
setIdleTimeout
setIdleTimeout
...
@@ -202,6 +203,29 @@ _idleCallRate = 200
...
@@ -202,6 +203,29 @@ _idleCallRate = 200
"""
"""
def
idleReset
():
"""
Reset the internal :func:`idle` queue state.
In a normal execution environment, this function will never need to be
called. However, in an execution environment where multiple ``wx.App``
instances are created, run, and destroyed sequentially, this function
will need to be called after each ``wx.App`` has been destroyed.
Otherwise the ``idle`` function will not work during exeution of
subsequent ``wx.App`` instances.
"""
global
_idleRegistered
global
_idleQueue
global
_idleQueueDict
global
_idleTimer
global
_idleCallRate
_idleRegistered
=
False
_idleQueue
=
queue
.
Queue
()
_idleQueueDict
=
{}
_idleTimer
=
None
_idleCallRate
=
200
def
getIdleTimeout
():
def
getIdleTimeout
():
"""
Returns the current ``wx`` idle loop time out/call rate.
"""
Returns the current ``wx`` idle loop time out/call rate.
"""
"""
...
@@ -373,7 +397,9 @@ def idle(task, *args, **kwargs):
...
@@ -373,7 +397,9 @@ def idle(task, *args, **kwargs):
argument. If ``True``, and a ``wx.MainLoop`` is not
argument. If ``True``, and a ``wx.MainLoop`` is not
running, the task is enqueued anyway, under the
running, the task is enqueued anyway, under the
assumption that a ``wx.MainLoop`` will be started in
assumption that a ``wx.MainLoop`` will be started in
the future.
the future. Note that another call to ``idle`` must
be made after the ``MainLoop`` has started for the
original task to be executed.
All other arguments are passed through to the task function.
All other arguments are passed through to the task function.
...
@@ -413,10 +439,12 @@ def idle(task, *args, **kwargs):
...
@@ -413,10 +439,12 @@ def idle(task, *args, **kwargs):
skipIfQueued
=
kwargs
.
pop
(
'
skipIfQueued
'
,
False
)
skipIfQueued
=
kwargs
.
pop
(
'
skipIfQueued
'
,
False
)
alwaysQueue
=
kwargs
.
pop
(
'
alwaysQueue
'
,
False
)
alwaysQueue
=
kwargs
.
pop
(
'
alwaysQueue
'
,
False
)
if
alwaysQueue
or
_haveWX
():
havewx
=
_haveWX
()
if
havewx
or
alwaysQueue
:
import
wx
import
wx
if
not
_idleRegistered
:
if
havewx
and
(
not
_idleRegistered
)
:
app
=
wx
.
GetApp
()
app
=
wx
.
GetApp
()
app
.
Bind
(
wx
.
EVT_IDLE
,
_wxIdleLoop
)
app
.
Bind
(
wx
.
EVT_IDLE
,
_wxIdleLoop
)
...
...
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