Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor 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
mesonium
gajim
Commits
061c9995
Commit
061c9995
authored
2 years ago
by
Daniel Brötzmann
Browse files
Options
Downloads
Patches
Plain Diff
chore: TaskManager: Add type annotations
parent
efaf720e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gajim/common/app.py
+2
-1
2 additions, 1 deletion
gajim/common/app.py
gajim/common/task_manager.py
+7
-7
7 additions, 7 deletions
gajim/common/task_manager.py
pyrightconfig.json
+1
-0
1 addition, 0 deletions
pyrightconfig.json
with
10 additions
and
8 deletions
gajim/common/app.py
+
2
−
1
View file @
061c9995
...
...
@@ -62,6 +62,7 @@
from
gajim.common.cert_store
import
CertificateStore
from
gajim.common.call_manager
import
CallManager
from
gajim.common.preview
import
PreviewManager
from
gajim.common.task_manager
import
TaskManager
interface
=
cast
(
types
.
InterfaceT
,
None
)
...
...
@@ -112,7 +113,7 @@ def __init__(self):
preview_manager
=
cast
(
'
PreviewManager
'
,
None
)
task_manager
=
None
task_manager
=
cast
(
'
TaskManager
'
,
None
)
# These will be set in app.gui_interface.
idlequeue
=
cast
(
IdleQueue
,
None
)
...
...
This diff is collapsed.
Click to expand it.
gajim/common/task_manager.py
+
7
−
7
View file @
061c9995
...
...
@@ -14,7 +14,7 @@
from
__future__
import
annotations
from
typing
import
List
from
typing
import
Optional
import
functools
import
queue
...
...
@@ -26,16 +26,16 @@
class
TaskManager
:
def
__init__
(
self
):
self
.
_timeout
=
None
self
.
_queue
=
queue
.
PriorityQueue
()
def
__init__
(
self
)
->
None
:
self
.
_timeout
:
Optional
[
int
]
=
None
self
.
_queue
:
queue
.
PriorityQueue
[
Task
]
=
queue
.
PriorityQueue
()
def
_start_worker
(
self
)
->
None
:
self
.
_timeout
=
GLib
.
timeout_add_seconds
(
2
,
self
.
_process_queue
)
def
_process_queue
(
self
)
->
bool
:
log
.
info
(
'
%s tasks queued
'
,
self
.
_queue
.
qsize
())
requeue
=
[]
requeue
:
list
[
Task
]
=
[]
while
not
self
.
_queue
.
empty
():
task
=
self
.
_queue
.
get_nowait
()
if
task
.
is_obsolete
():
...
...
@@ -63,7 +63,7 @@ def _process_queue(self) -> bool:
self
.
_timeout
=
None
return
False
def
_requeue_tasks
(
self
,
tasks
:
L
ist
[
Task
])
->
bool
:
def
_requeue_tasks
(
self
,
tasks
:
l
ist
[
Task
])
->
bool
:
if
not
tasks
:
return
False
...
...
@@ -81,7 +81,7 @@ def add_task(self, task: Task) -> None:
@functools.total_ordering
class
Task
:
def
__init__
(
self
,
priority
:
int
=
0
):
def
__init__
(
self
,
priority
:
int
=
0
)
->
None
:
self
.
priority
=
priority
self
.
_obsolete
=
False
...
...
This diff is collapsed.
Click to expand it.
pyrightconfig.json
+
1
−
0
View file @
061c9995
...
...
@@ -37,6 +37,7 @@
"gajim/common/setting_values.py"
,
"gajim/common/sound.py"
,
"gajim/common/storage/"
,
"gajim/common/task_manager.py"
,
"gajim/gtk/about.py"
,
"gajim/gtk/account_page.py"
,
"gajim/gtk/account_side_bar.py"
,
...
...
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