Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
i3-woman
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
i3-woman
Commits
2943011c
Commit
2943011c
authored
2 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Qt util: Job cancel
parent
3a7e7f18
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
woman/qt_util.py
+27
-10
27 additions, 10 deletions
woman/qt_util.py
with
27 additions
and
10 deletions
woman/qt_util.py
+
27
−
10
View file @
2943011c
...
@@ -3,6 +3,7 @@ from PyQt5.QtGui import *
...
@@ -3,6 +3,7 @@ from PyQt5.QtGui import *
from
PyQt5.QtWidgets
import
*
from
PyQt5.QtWidgets
import
*
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
enum
import
Enum
import
re
import
re
import
types
import
types
import
traceback
import
traceback
...
@@ -361,6 +362,13 @@ class QLabelOpeningBracket(QLabel):
...
@@ -361,6 +362,13 @@ class QLabelOpeningBracket(QLabel):
_qt_jobs
=
set
()
_qt_jobs
=
set
()
class
QtJobState
(
Enum
):
WAITING
=
1
RUNNING
=
2
DONE
=
3
CANCELED
=
4
class
QtJob
:
class
QtJob
:
def
__init__
(
self
,
f
):
def
__init__
(
self
,
f
):
_qt_jobs
.
add
(
self
)
_qt_jobs
.
add
(
self
)
...
@@ -369,11 +377,13 @@ class QtJob:
...
@@ -369,11 +377,13 @@ class QtJob:
self
.
timer
.
setSingleShot
(
True
)
self
.
timer
.
setSingleShot
(
True
)
self
.
timer
.
timeout
.
connect
(
self
.
_run
)
self
.
timer
.
timeout
.
connect
(
self
.
_run
)
self
.
timer
.
start
(
0
)
self
.
timer
.
start
(
0
)
self
.
state
=
QtJobState
.
WAITING
def
_clean
(
self
):
def
_clean
(
self
):
_qt_jobs
.
remove
(
self
)
_qt_jobs
.
remove
(
self
)
def
_run
(
self
):
def
_run
(
self
):
if
self
.
state
==
QtJobState
.
WAITING
:
try
:
try
:
r
=
self
.
f
.
send
(
None
)
r
=
self
.
f
.
send
(
None
)
print
(
r
)
print
(
r
)
...
@@ -385,6 +395,13 @@ class QtJob:
...
@@ -385,6 +395,13 @@ class QtJob:
else
:
else
:
self
.
timer
.
start
(
r
)
self
.
timer
.
start
(
r
)
def
cancel
(
self
):
if
self
.
state
==
QtJobState
.
RUNNING
:
raise
NotImplementedError
()
if
self
.
state
==
QtJobState
.
WAITING
:
self
.
state
=
QtJobState
.
CANCELED
self
.
f
.
close
()
@types.coroutine
@types.coroutine
def
qt_job_wait_ms
(
time_ms
):
def
qt_job_wait_ms
(
time_ms
):
yield
time_ms
yield
time_ms
...
...
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