Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event loop is closed #30

Open
taksalo opened this issue Jun 27, 2023 · 6 comments
Open

Event loop is closed #30

taksalo opened this issue Jun 27, 2023 · 6 comments

Comments

@taksalo
Copy link

taksalo commented Jun 27, 2023

Hello
Cant get my head around this:

Jun 27 14:27:34 localhost.localdomain systemd[1]: adsbcot.service: Scheduled restart job, restart counter is at 39.
Jun 27 14:27:34 localhost.localdomain systemd[1]: Stopped ADS-B to TAK Gateway.
Jun 27 14:27:34 localhost.localdomain systemd[1]: Started ADS-B to TAK Gateway.
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: Traceback (most recent call last):
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/local/bin/adsbcot", line 8, in
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: sys.exit(main())
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: ^^^^^^
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/local/lib/python3.11/site-packages/adsbcot/commands.py", line 31, in main
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: pytak.cli(name.split(".", maxsplit=1)[0])
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/local/lib/python3.11/site-packages/pytak/client_functions.py", line 395, in cli
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: asyncio.run(main(app_name, config), debug=debug)
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/lib64/python3.11/asyncio/runners.py", line 190, in run
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: return runner.run(main)
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: ^^^^^^^^^^^^^^^^
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/lib64/python3.11/asyncio/runners.py", line 118, in run
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: return self._loop.run_until_complete(task)
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/lib64/python3.11/asyncio/base_events.py", line 653, in run_until_complete
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: return future.result()
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: ^^^^^^^^^^^^^^^
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/local/lib/python3.11/site-packages/pytak/client_functions.py", line 293, in main
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: clitool.add_tasks(create_tasks(config, clitool))
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/local/lib/python3.11/site-packages/adsbcot/functions.py", line 88, in create_tasks
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: raise ValueError
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: ValueError
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: Exception ignored in: <function DatagramStream.del at 0x7f03b59b5f80>
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: Traceback (most recent call last):
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/local/lib/python3.11/site-packages/pytak/asyncio_dgram/aio.py", line 49, in del
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/lib64/python3.11/asyncio/selector_events.py", line 839, in close
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/lib64/python3.11/asyncio/base_events.py", line 761, in call_soon
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/lib64/python3.11/asyncio/base_events.py", line 519, in _check_closed
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: RuntimeError: Event loop is closed
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: Exception ignored in: <function DatagramStream.del at 0x7f03b59b5f80>
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: Traceback (most recent call last):
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/local/lib/python3.11/site-packages/pytak/asyncio_dgram/aio.py", line 49, in del
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/lib64/python3.11/asyncio/selector_events.py", line 839, in close
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/lib64/python3.11/asyncio/base_events.py", line 761, in call_soon
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: File "/usr/lib64/python3.11/asyncio/base_events.py", line 519, in _check_closed
Jun 27 14:27:34 localhost.localdomain adsbcot[6686]: RuntimeError: Event loop is closed
Jun 27 14:27:34 localhost.localdomain systemd[1]: adsbcot.service: Main process exited, code=exited, status=1/FAILURE
Jun 27 14:27:34 localhost.localdomain systemd[1]: adsbcot.service: Failed with result 'exit-code'.
Jun 27 14:27:39 localhost.localdomain systemd[1]: adsbcot.service: Service RestartSec=5s expired, scheduling restart.
Jun 27 14:27:39 localhost.localdomain systemd[1]: adsbcot.service: Scheduled restart job, restart counter is at 40.

Has it something to do with Python version and event handling or anything else.
Best regards

@ampledata
Copy link
Collaborator

What happens if you run adsbcot manually? and if you're using a custom config, can you share that?

@taksalo
Copy link
Author

taksalo commented Jun 28, 2023

I disabled the service and ran: adsbcot
This is what happened.
(I'm running on Rocky Linux 8)

[root@localhost ~]# adsbcot
2023-06-28 09:43:05,926 pytak INFO - CoT_URL Dest: udp://239.2.3.1:6969
2023-06-28 09:43:05,926 pytak INFO - Run: <class 'pytak.classes.CLITool'>
2023-06-28 09:43:05,930 pytak INFO - Run: <class 'pytak.classes.TXWorker'>
2023-06-28 09:43:05,930 pytak INFO - Run: <class 'pytak.classes.RXWorker'>
2023-06-28 09:43:05,930 pytak INFO - Running <class 'adsbcot.classes.ADSBWorker'>
2023-06-28 09:43:05,930 pytak INFO - Complete: <Task finished name='Task-4' coro=<ADSBWorker.run() done, defined at /usr/local/lib/python3.11/site-packages/adsbcot/classes.py:146> exception=FileNotFoundError(2, 'No such file or directory')>
Task exception was never retrieved
future: <Task finished name='Task-4' coro=<ADSBWorker.run() done, defined at /usr/local/lib/python3.11/site-packages/adsbcot/classes.py:146> exception=FileNotFoundError(2, 'No such file or directory')>
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/adsbcot/classes.py", line 189, in run
inotify.add_watch(
File "/usr/local/lib/python3.11/site-packages/asyncinotify/init.py", line 450, in add_watch
raise e
File "/usr/local/lib/python3.11/site-packages/asyncinotify/init.py", line 447, in add_watch
wd = _ffi.libc.inotify_add_watch(self.fd, bytepath, mask)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/asyncinotify/_ffi.py", line 24, in check_return
raise OSError(errno, os.strerror(errno))
FileNotFoundError: [Errno 2] No such file or directory: PosixPath('/run/dump1090-fa')

I guess in this case it just uses defaults? Not any config parameters?

@ampledata
Copy link
Collaborator

Hey @taksalo. The default behavior is to read decoded ADS-B data from the filesystem at /run/dump1090-fa/aircraft.json. See: https://adsbcot.readthedocs.io/en/latest/config.html

To change this location, or to use another method to read the ADS-B data, you'll need to set the FEED_URL parameter, see: https://adsbcot.readthedocs.io/en/latest/config.html#example-configurations

@taksalo
Copy link
Author

taksalo commented Jun 30, 2023

Ok thank you very much for the help so far.
I'm running dump1090 on the same server and tried
[adsbcot]
COT_URL = udp://239.2.3.1:6969
FEED_URL = http://127.0.0.1:30002

Seems to be working better, output is now
[root@localhost ~]# adsbcot -c /etc/adsbcot.ini
2023-06-30 10:11:44,650 pytak INFO - CoT_URL Dest: udp://239.2.3.1:6969
2023-06-30 10:11:44,650 pytak INFO - Run: <class 'pytak.classes.CLITool'>
2023-06-30 10:11:44,651 pytak INFO - Run: <class 'pytak.classes.TXWorker'>
2023-06-30 10:11:44,651 pytak INFO - Running <class 'adsbcot.classes.ADSBWorker'>
2023-06-30 10:11:44,651 pytak INFO - <class 'adsbcot.classes.ADSBWorker'> polling every 3s: http://127.0.0.1:30002
2023-06-30 10:11:44,652 pytak INFO - Run: <class 'pytak.classes.RXWorker'>

I will try to get the TAK server to view the CoT messages. Havent got so far yet.

//taksalo

@ampledata
Copy link
Collaborator

Ok, I think you might be confused about the FEED_URL parameter. Currently you're using http://127.0.0.1:30002, however, the 30002 port should use a URL like: tcp+raw://127.0.0.1:30002 or tcp+beast://127.0.0.1:30002.

@taksalo
Copy link
Author

taksalo commented Jul 12, 2023

Ok, thanks again.
Since I didnt install with raw or beast support I will try using:

FEED_URL = http://localhost:8080/data/aircraft.json
or the json file if i can locate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants