Repository navigation
asyncio-related shutdown problem, "Future object is not initialized." #273
Copy link
Copy link
Closed
Description
Issue type
Bug
How did you install PythonMonkey?
Source
OS platform and distribution
No response
Python version (python --version)
3.10.12
PythonMonkey version (pip show pythonmonkey)
0.3.1.dev42+6b5fb9d
Bug Description
This program will crash with a segfault:
#! /usr/bin/env python3
import pythonmonkey as pm
async def go():
dcpConfig = pm.globalThis.dcpConfig
Connection = pm.globalThis.dcp.protocol.Connection
target = dcpConfig.scheduler.services.jobSubmit
conn = pm.new(Connection)(target)
await conn.connect()
quit()
dcp_client = pm.require('dcp-client/index.py') # should be just dcp-client, see pm issue 247
dcp_client['init'](go)The error is:
[~/git2/python-launch-job] dev-wes:wes# ./kaboom.py
Traceback (most recent call last):
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
self.run_forever()
File "/usr/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
self._run_once()
File "/usr/lib/python3.10/asyncio/base_events.py", line 1909, in _run_once
handle._run()
File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/home/wes/git2/python-launch-job/node_modules/dcp-client/index.py", line 60, in load_dcp_client
cb_retval = await callback()
File "/home/wes/git2/python-launch-job/./kaboom.py", line 11, in go
quit()
File "/usr/lib/python3.10/_sitebuiltins.py", line 26, in __call__
raise SystemExit(code)
SystemExit: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/wes/git2/python-launch-job/./kaboom.py", line 14, in <module>
dcp_client['init'](go)
File "/home/wes/git2/python-launch-job/node_modules/dcp-client/index.py", line 67, in init
asyncio.run(load_dcp_client(callback))
File "/usr/lib/python3.10/asyncio/runners.py", line 47, in run
_cancel_all_tasks(loop)
File "/usr/lib/python3.10/asyncio/runners.py", line 68, in _cancel_all_tasks
if task.exception() is not None:
asyncio.exceptions.InvalidStateError: Future object is not initialized.
Segmentation fault (core dumped)
Removing the quit causes it to hang forever, until you hit ^C, in which case you get basically the same error stack but no segfault.
### What branch of PythonMonkey were you developing on? (If applicable)
wes/DCP-4054/make-dcp-client-grok-pythonmonkey
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
- StatusShow more project fieldsDone
Activity
wesgarland commentedon Mar 9, 2024
What's interesting is that my standalone XHR demo program doesn't cause any problems
This suggests that it could be outstanding timers triggering the issue. dcp-client uses a ton of those.
philippedistributive commentedon Mar 13, 2024
@wesgarland any core dump/stack trace lying around?
wesgarland commentedon Mar 14, 2024
Sorry, no. There's a kernel extension on my container intercepting my core dumps, and I don't want to reboot it to get rid of it until Jack is back at work. Because if I doesn't come back up I can't fix it.
philippedistributive commentedon Apr 4, 2024
from @Xmader in slack:
The error is because when calling quit() there're still some background jobs running. It cannot be fixed directly in PythonMonkey but we need to see how to properly cancel the background timers in DCP.
wesgarland commentedon Apr 10, 2024
We are not changing how DCP handles timers.
This is why we are supposed to copy the node references API stuff for PythonMonkey.