Skip to content

asyncio.run() causes crashes #324

Closed
Closed
@bryaan

Description

@bryaan

PythonCall

I have to use the following function otherwise I get crashes that interestingly enough don't crash the julia program. But it does print a python stacktrace to console.

In addition, if using this in concurrent for loop with @sync and @async it looks like the code runs sequentially.

function asyncio_run(coro)
    loop = asyncio.get_event_loop()
    loop.run_until_complete(coro)

    # This is the recommended way but keeps crashing 
    # Interestingly it doesnt error in julia, it just prints a python error to console.
    # asyncio.run(coro)
end
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x29da04d30>
transport: <_SelectorSocketTransport closing fd=24>
Traceback (most recent call last):
  File "/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/selector_events.py", line 924, in write
    n = self._sock.send(data)
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 690, in _process_write_backlog
    self._transport.write(chunk)
  File "/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/selector_events.py", line 930, in write
    self._fatal_error(exc, 'Fatal write error on socket transport')
  File "/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/selector_events.py", line 725, in _fatal_error
    self._force_close(exc)
  File "/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/selector_events.py", line 737, in _force_close
    self._loop.call_soon(self._call_connection_lost, exc)
  File "/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 753, in call_soon
    self._check_closed()
  File "/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions