Skip to content

Commit

Permalink
Merge pull request #35 from pollen-robotics/34-get_producer_list-cann…
Browse files Browse the repository at this point in the history
…ot-be-called-from-thread

34 get producer list cannot be called from thread
  • Loading branch information
pierre-rouanet authored Jan 3, 2024
2 parents 7dbe4e2 + b4651de commit e9d1745
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
15 changes: 5 additions & 10 deletions src/example/get_producer_list.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import argparse
import asyncio
import logging
from gst_signalling import GstSignalling, utils

from gst_signalling import utils

async def get_producer_list(args: argparse.Namespace) -> None:

def get_producer_list(args: argparse.Namespace) -> None:
"""Main function."""
if args.verbose:
logging.basicConfig(level=logging.DEBUG)

signalling = GstSignalling(host="localhost", port=8443)
await signalling.connect()

producers = await utils.get_producer_list(signalling)
producers = utils.get_producer_list(args.signalling_host, args.signalling_port)

if producers:
print("List received, producers:")
Expand All @@ -21,8 +18,6 @@ async def get_producer_list(args: argparse.Namespace) -> None:
else:
print("List received, no producers.")

await signalling.close()


def main() -> None:
parser = argparse.ArgumentParser(description="Get gstreamer producer list")
Expand All @@ -31,7 +26,7 @@ def main() -> None:
parser.add_argument("--verbose", "-v", action="count")
args = parser.parse_args()

asyncio.run(get_producer_list(args))
get_producer_list(args)


if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions src/gst_signalling/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def on_list(found_producers: Dict[str, Dict[str, str]]) -> None:

return producers

loop = asyncio.get_event_loop()
return loop.run_until_complete(get_list())
return asyncio.run(get_list())


def find_producer_peer_id_by_name(host: str, port: int, name: str) -> str:
Expand Down

0 comments on commit e9d1745

Please sign in to comment.