junzis / pyModeS

Python decoder for Mode S and ADS-B signals
GNU General Public License v3.0
527 stars 151 forks source link

Not a bug, just looking for help with using your library in a python async structure #122

Closed deepcoder closed 2 years ago

deepcoder commented 2 years ago

1st, just want to thank you for your great work on this! Very educational, interesting, fun and useful to explore with your code.

I am total noob here, so apologies up front. I am trying to create a python program based on your example. I would like the program to run nonstop, retrieving the local ads-b data and comparing it against ICAO code that is read from a Google Spreadsheet and doing some processing based on whether a ICOA code is found.

I have a version working using the Python thread library, however I am told that using Python' async library would be more efficient and perhaps modern.

My basic goal is to allow people to update a Google Sheet randomly, read in these changes to a Python dictionary and do processing based on such. Looking forward, I would ideally like to instantiate callbacks based on this dynamic data that did different processing, for example based on ICAO and/or message type.

I tried to use your libraries with Python async, however I could not figure out how to 'launch' my 'handle_message' in a 'async' way.

Any advice or code example on how to do multiprocessing with your libraries and async would be greatly appreciated.

Thanks!

xoolive commented 2 years ago

async Python is a modern way to do concurrency in a single threaded program, there's nothing blocking on the handle_message side, so I am not sure what you mean here. You would appreciate async access to a RTLSDR dongle but that's not the job of pyModeS (and as a matter of fact, it's part of pyrtlsdr.

deepcoder commented 2 years ago

Thank you for your reply and information. However, to my original question, if you could expand your code example to show a 'async' version of your example below, that would be very helpful. When I tried to make my main and my override method 'handle_messages' 'async' it did NOT work. I am a noob here, however, your example instantiates your 'run' method, not my 'async'ed 'handle_messages' method. And since your 'run' method is NOT 'async', as a result I believe my 'async' 'handle_message' is not instantiated in a 'async' way and I get an error message and my override 'handle_message' method is NOT called, and my program just hangs.

Again, if you can provide a 'async' ed version of your example or some expanded guidance that would be very helpful. Thx!

(https://github.com/junzis/pyModeS#customize-the-streaming-module)