Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Python Briar Wrapper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
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
briar
Python Briar Wrapper
Commits
94861a3a
Commit
94861a3a
authored
4 years ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
Make signal ids stable
This commit makes signal ids stable by always incrementing the id number.
parent
e5557c47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar_wrapper/models/socket_listener.py
+11
-6
11 additions, 6 deletions
briar_wrapper/models/socket_listener.py
with
11 additions
and
6 deletions
briar_wrapper/models/socket_listener.py
+
11
−
6
View file @
94861a3a
...
...
@@ -16,19 +16,24 @@ class SocketListener(): # pylint: disable=too-few-public-methods
def
__init__
(
self
,
api
):
self
.
_api
=
api
self
.
_signals
=
lis
t
()
self
.
_signals
=
dic
t
()
self
.
_signals_lock
=
Lock
()
self
.
_highest_signal_id
=
-
1
self
.
_start_websocket_thread
()
def
connect
(
self
,
event
,
callback
):
self
.
_signals_lock
.
acquire
()
# TODO: Signal ID should be stable after disconnects
signal_id
=
len
(
self
.
_signals
)
self
.
_signals
.
append
({
signal_id
=
self
.
_add_signal
(
event
,
callback
)
self
.
_signals_lock
.
release
()
return
signal_id
def
_add_signal
(
self
,
event
,
callback
):
self
.
_highest_signal_id
+=
1
signal_id
=
self
.
_highest_signal_id
self
.
_signals
[
signal_id
]
=
{
"
event
"
:
event
,
"
callback
"
:
callback
})
self
.
_signals_lock
.
release
()
}
return
signal_id
def
_start_websocket_thread
(
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