Skip to content

Error logged to console when shutting down #289

@migus-rs

Description

@migus-rs

Describe the bug
When running EMBArk using run-server.sh exiting the application by pressing Ctrl-C leads to the following error message before the shutdown happens.

^C
worker: Hitting Ctrl+C again will initiate cold shutdown, terminating all running tasks!

worker: Warm shutdown (MainProcess)
Shutting down all operations!
Traceback (most recent call last):
  File "/var/www/.venv/bin/daphne", line 8, in <module>
    sys.exit(CommandLineInterface.entrypoint())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/.venv/lib/python3.12/site-packages/daphne/cli.py", line 171, in entrypoint
    cls().run(sys.argv[1:])
  File "/var/www/.venv/lib/python3.12/site-packages/daphne/cli.py", line 291, in run
    self.server.run()
  File "/var/www/.venv/lib/python3.12/site-packages/daphne/server.py", line 150, in run
    reactor.run(installSignalHandlers=self.signal_handlers)
  File "/var/www/.venv/lib/python3.12/site-packages/twisted/internet/asyncioreactor.py", line 253, in run
Shutting down all operations!
    self._asyncioEventloop.run_forever()
  File "/usr/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/lib/python3.12/asyncio/base_events.py", line 1949, in _run_once
    event_list = self._selector.select(timeout)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/selectors.py", line 468, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/embark/uploader/__init__.py", line 19, in _stop_handler
    finish_execution.send(sender='system')
  File "/var/www/.venv/lib/python3.12/site-packages/django/dispatch/dispatcher.py", line 189, in send
    response = receiver(signal=self, sender=sender, **named)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/embark/uploader/boundedexecutor.py", line 500, in sigint_handler
    BoundedExecutor.shutdown()
  File "/var/www/embark/uploader/boundedexecutor.py", line 234, in shutdown
    for analysis_ in running_analysis_list:
  File "/var/www/.venv/lib/python3.12/site-packages/django/db/models/query.py", line 386, in __iter__
    self._fetch_all()
  File "/var/www/.venv/lib/python3.12/site-packages/django/db/models/query.py", line 1954, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/.venv/lib/python3.12/site-packages/django/db/models/query.py", line 93, in __iter__
    results = compiler.execute_sql(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/.venv/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1621, in execute_sql
    cursor = self.connection.cursor()
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 24, in inner
    raise SynchronousOnlyOperation(message)
django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.
 193568000/tcp:           
./run-server.sh: line 415: 19354 Killed                  sudo -u www-embark "${PIPENV_COMMAND}" run daphne --access-log /var/www/logs/daphne.log -e ssl:8000:privateKey=/var/www/conf/cert/embark-ws.local.key:certKey=/var/www/conf/cert/embark-ws.local.crt -b "${BIND_IP}" -p 8001 -s embark-ws.local embark.asgi:application

To Reproduce
Steps to reproduce the behavior:

  1. EMBArk installation (default mode)
  2. Start EMBArk: sudo ./run-server.sh
  3. After startup completes, shut down EMBArk using Ctrl-C
  4. See error

Expected behavior
While expecting some warnings on shutdown, an error about incorrect thread contexts seems rather severe (especially involving database operations).

Screenshots
/

Desktop (please complete the following information):

  • OS: Ubuntu 24.04 VM

Additional context
/

Metadata

Metadata

Assignees

No one assigned

    Labels

    EMBArkbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions