Skip to content

Commit

Permalink
gattlib-py/gattlib/mainloop: Ensure we are not overwriting the mainloop
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviermartin committed Mar 13, 2024
1 parent faaf234 commit 785f4d1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gattlib-py/gattlib/mainloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def _user_thread_main(task):
def run_mainloop_with(task):
global gobject_mainloop, task_returned_code, task_exception

if gobject_mainloop:
raise RuntimeError("A mainloop is already running")

# Ensure GLib's threading is initialized to support python threads, and
# make a default mainloop that all DBus objects will inherit. These
# commands MUST execute before any other DBus commands!
Expand Down Expand Up @@ -70,3 +73,5 @@ def run_mainloop_with(task):
# We assume that if we exit with keyboard interrupt than it is not the expected
# behaviour and we return -1
return -2
finally:
gobject_mainloop = None

0 comments on commit 785f4d1

Please sign in to comment.