dabeaz / curio

Good Curio!
Other
4.01k stars 240 forks source link

Error when shutting down, self._shutdown_funcs set to None #287

Closed kdart closed 4 years ago

kdart commented 5 years ago

I sometimes get this traceback at the end of my program's run.

Traceback (most recent call last): File "/usr/lib/python3.6/contextlib.py", line 99, in exit self.gen.throw(type, value, traceback) File "/usr/local/lib/python3.6/dist-packages/curio/meta.py", line 42, in running yield File "/usr/local/lib/python3.6/dist-packages/curio/kernel.py", line 145, in run self._runner.send(None) File "/usr/local/lib/python3.6/dist-packages/curio/kernel.py", line 597, in _run_coro _init_loopback() File "/usr/local/lib/python3.6/dist-packages/curio/kernel.py", line 276, in _init_loopback kernel._call_at_shutdown(kernel._notify_sock.close) File "/usr/local/lib/python3.6/dist-packages/curio/kernel.py", line 132, in _call_at_shutdown self._shutdown_funcs.append(func) AttributeError: 'NoneType' object has no attribute 'append'

Looking at the code, the self._shutdown_funcs gets set to None in the run method. It could be I'm doing something wrong (not using this right), but I thought I'd file a bug for this in the hopes of whatever I'm doing wrong might also get a better error.

kdart commented 5 years ago

This seems to happen if you run Kernel.run(..., shutdown=True) a second time. This is a bug on the users part. I'll see if I can make this error more clear.

dabeaz commented 5 years ago

There was a previous bug-report about something similar to this somewhat recently. I think I might have fixed it, but my memory is now fuzzy. I'll take a look.

dabeaz commented 5 years ago

I've added a clarifying exception to help with this. May revisit later. Perhaps it's okay to restart a kernel that's been shut down. I'd just need to investigate it in a bit more detail.